获取非交互式 shell 的“top”输出

获取非交互式 shell 的“top”输出

我想为网络应用程序实现 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.

相关内容