我想为网络应用程序实现 top 功能。是否可以top
在非交互式 shell 中获取命令的输出?
答案1
top -b -n 1
从man top
:
-b : Batch mode operation Starts top in 'Batch mode', which could be useful for sending output from top to other programs or to a file. In this mode, top will not accept input and runs until the iterations limit you've set with the '-n' command-line option or until killed.