Question

Linux server is like this: Linux hostname 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

And the ps aux shows incorrect CPU usage and the value is not reasonable. The value is not update frequently as top.

For example, for the same process, ps shows the cpu usage is 210.0 and keep shows that value in several execution. But in another terminal, top shows the cup usage keeps changing between 1xx to 2xx. the top's value is reasonable. Any idea why ps aux doesn't works well?

Was it helpful?

Solution

Both should work but they work in different ways:

From MAN of ps:

%cpu       %CPU     cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been
                    running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you are lucky. (alias pcpu).

and top

  k: %CPU  --  CPU usage
          The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.  In a true SMP envi-
          ronment, if ’Irix mode’ is Off, top will operate in ’Solaris mode’ where a task’s cpu usage will be divided by the total number of CPUs.
          You toggle ’Irix/Solaris’ modes with the ’I’ interactive command.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top