How does Linux measure elapsed time of a particular process?

527 Views Asked by At

When I look at ps command manual, it offers elapsed time measurement for each process, no matter this process is still alive. However, when I check /proc//stat, it only records the start time, CPU time and User time. I tried to add CPU time and User time, but the result doesn't match what elapsed time shows. Hence I'd like to look for suggestion on the direction to measure elapsed time.

1

There are 1 best solutions below

2
Chris Dodd On

The elapsed time displayed by ps is just current time - start time. So literally just the elapsed wall clock time since the process started.

The utime and stime in /proc/stat are a measure of the total amount of time the process has actually been running on the system (user time and system time), not counting any time spent blocked waiting for something.