cha*_*aos 28
该-n开关是你搜索的内容:
user@host:~$ top -n 1
Run Code Online (Sandbox Code Playgroud)
请参阅联机帮助页
-n : Number of iterations limit as: -n number
Specifies the maximum number of iterations, or frames, top should produce before ending.
Run Code Online (Sandbox Code Playgroud)
如果您想停止top命令,只需按q。
注意:如果您倾向于top在脚本中使用,我需要说top不是用于脚本,ps而是使用。
请注意,如果您想为脚本保留“top”命令,您可以使用-b选项(“-b”选项表示“批处理模式操作”),此选项允许您将输出重定向到文件中。
例子:
top -bn 1 2>&1 1> /tmp/topNtop -ban 1 2>&1 1> /tmp/topAN