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
身在半空 阅读(2559)
评论(1) 编辑 收藏