Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to find a tool such as top, that runs in a terminal, but that keeps a cumulative total of real/user/system time used.

share|improve this question

4 Answers 4

up vote 3 down vote accepted

Found it... "top -S"

share|improve this answer

top already keeps a cumulative total of time spent on the cpu (user+system) I believe. That's what's listed in the TIME+ field:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 5117 michael   20   0  508m 238m  30m R   16  6.1   7:55.47 firefox
 3135 root      20   0  194m  53m  14m S    8  1.4  26:37.08 X
 4359 michael   20   0  117m  83m  14m S    1  2.1  17:59.34 gnome-panel

'real time' probably isn't that interesting to watch - it's just the amount of elapsed time since the process started.

If you're interested in hacking it up yourself, everything you need is in /proc/*/stat :)

Or try using ps:

ps -eo pid,user,args,etime,time,%cpu --sort %cpu
watch -n1 ps -eo pid,user,args,etime,time,%cpu --sort -%cpu

(the very last line is probably closest to what you actually ask :)

share|improve this answer

I don't know if I understand correctly, but top -a (or top -c a) is the cumulative mode of top on Mac OS X.

share|improve this answer
    
Tried it... "top: unknown argument 'a'" –  dacracot Oct 13 '09 at 19:26
    
It's top -S for the version I have. –  Dennis Williamson Oct 13 '09 at 19:27
    
Strange, on Mac OS X, there's no -S argument. Different OS, different arguments. –  Studer Oct 13 '09 at 19:39
    
Not that strange. I work on Linux, Solaris, and AIX, and they all use different flags for common things. It'll make you crazy. –  Satanicpuppy Oct 13 '09 at 19:57

The only problem with "top -S", "ps --cumulative" or "pidstat -T ALL" that they only add exited processes' times to parents'. Thus you can't monitor CPU time usage real time, if child processes don't exit too often.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.