批处理模式下的CPU使用率 [英] CPU usage in top batch mode

查看:214
本文介绍了批处理模式下的CPU使用率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,让我疯了。我使用以下命令以批处理模式运行,



top -b -n 1



问题是我可以在批处理模式下运行100次,但CPU使用率从未改变超过原始值。内存使用情况按预期变化,但CPU保持不变。如果我同时在不同的窗口中运行另一个顶部,CPU使用率在该顶部更改,但不是在批处理模式下顶部。



基本上,CPU统计信息似乎在批处理模式下更改,在交互模式下更改。有人知道为什么吗?
自己尝试,运行上面的命令几次,观察CPU使用率保持不变,然后在交互模式下运行top,并观察CPU使用率不断变化。



(注意这不是一个简单的例子。 top 的较新版本的情况会更长)。


I have a problem that makes me mad. I am running top in batch mode with the following command,

top -b -n 1

The problem is I can run top in batch mode 100 times but the CPU usage never changes past the original value. The memory usage changes as expected but CPU stays the same. If I simultaneously run another top in a different window the CPU usage is changing for that top but not for the top in batch mode.

Basically CPU stats don't seem to change in batch mode and do in interactive mode. Does anyone know why? Try it yourself, run the above command a few times and observe the CPU usage staying the same then run top in interactive mode and observe the CPU usage constantly changing.

解决方案

On the first iteration, it is showing you the average CPU usage since system startup.

(Note that this is no longer the case for newer versions of top).

这篇关于批处理模式下的CPU使用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆