Linux系統中top命令是交互式命令,故腳本中執行時會卡住,不再執行下一個命令。
解決辦法是:top -n 1。
程序調用top命令時常會報
top: failed tty get 錯誤,此時使用top -b。
-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.
-n : Number of iterations limit as: -n number
Specifies the maximum number of iterations, or frames, top should produce before ending.
posted on 2011-12-06 15:39
身在半空 閱讀(2566)
評論(1) 編輯 收藏