为什么ps aux显示与top有很大不同的cpu使用率

时间:2013-12-20 06:36:00

标签: linux cpu-usage ps

Linux服务器是这样的: 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

并且ps aux显示不正确的CPU使用率且值不合理。该值不会经常更新为top

例如,对于相同的进程,ps显示cpu使用率为210.0并且在多次执行中保持显示该值。但在另一个终端中,top显示杯子的使用量在1xx到2xx之间不断变化。顶部的价值是合理的。知道为什么ps aux不能正常工作吗?

1 个答案:

答案 0 :(得分:2)

两者都应该有效,但它们的工作方式不同:

来自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).

和顶部

  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.