how to determine the runtime and start time of a Linux process

Posted by fkonietzny on Apr 1, 2012 9:46 AM EDT
a Linux sysadmin blog; By Frederik Konietzny
Mail this story
Print this story

Yesterday, I needed to determine the runtime of a Linux process for a monitoring script. Cos the format for start_time of the ps command may change if the process was not started in the same year, I decided to take the neccessary informations from the /proc/<PID>/stat file.

Yesterday, I needed to determine the runtime of a Linux process for a monitoring script. Cos the format for start_time of the ps command may change if the process was not started in the same year, I decided to take the neccessary informations from the /proc/<PID>/stat file.

In this file the process start time since boot is defined at the twenty-second field, expressed in Jiffies – the scale unit of the system timer. (One Jiffie is one tick of the system timer).

To convert Jiffies to seconds I just have to divide the number of Jiffies by the frequency (hertz) of the system timer, which is defined in the Linux Kernel header file include/asm-generic/param.h. The frequency may differ between Linux kernel versions and hardware platform! On my Linux systems the frequency is 100 HZ.

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: Linux

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.