On 11/19/05, Anders Norrbring
I don't understand a diff I get in outputs from 'top' and ps', can somebody please explain it?
If I run 'ps -A -o %cpu,%mem,comm' and grep for 'httpd', I get 0.0% CPU time. If I run top at the same time, I get 13.9% cpu load for httpd2-prefork.
ps and top express "cpu" differently. While ps calculates it by "total CPU time" divided by "time task is running" top shows the value as a percentage of overall CPU time. For ps it means: the longer a process is running without a high CPU utilization the smaller the value of %cpu gets (it converges to zero). It is different from top that displays this value as share of the CPU time since last screen update and is therefore more accurate in terms of "current CPU utilization". \Steve Thanks Steve! Is there a good way to get the 'top' values in a query similar to the ps command I tried to use? 'ps -A -o %cpu,comm' What I'm looking for is the cpu load value at the very moment I ask for it, no averages. Anders.