Linux系統(tǒng)中top命令是交互式命令,故腳本中執(zhí)行時(shí)會(huì)卡住,不再執(zhí)行下一個(gè)命令。
解決辦法是:top -n 1。
程序調(diào)用top命令時(shí)常會(huì)報(bào)
top: failed tty get 錯(cuò)誤,此時(shí)使用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)
評(píng)論(1) 編輯 收藏