Reputation: 101
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.
Upvotes: 3
Views: 9543
Reputation: 5577
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).
Upvotes: 2
Reputation: 7225
Use the linux command time. It record three kind of process running time. real: wall time. user: user space time. sys: kernel space time.
Find this link: The meaning of real, user, and sys in output of Linux time command
Upvotes: 0