How to determine a process running time?
After google about ps command, I can use ps command to get process running time by:
ps -eo pid,id,cmd,etime,time
Most of article I saw in google use etime (elapse time) to determine process run time.
But I also found an similar question in stackoverflow.com Getting execution time of a user process in Linux and he/she use time parameter?
So my question is, what is the different between etime and time parameter in ps command and which parameter is able to get actual running time of process.
etime measures "wall clock time", difference between now and the moment the process was started.
time (alias to cputime) measures how much time CPUs were busy executing process code. When the process is waiting for network or disk or just sleeps, this counter does not increase. When the process is using multiple threads to execute some code in parallel, this counter increases proportionally to number of CPUs busy with the process in question. time is normally much less than etime, unless the process does heavy calculations.
$ man ps
etime ELAPSED elapsed time since the process was started, in the form [[DD-]hh:]mm:ss.
time TIME cumulative CPU time, "[DD-]HH:MM:SS" format. (alias cputime).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With