Scripting

獲取非互動式 shell 的 top 輸出

  • February 1, 2021

我想為網路應用程序實現頂級功能。是否可以top在非互動式 shell 中獲取命令的輸出?

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.

引用自:https://unix.stackexchange.com/questions/255100