【发布时间】:2011-10-11 06:06:19
【问题描述】:
我想关注特定命令的输出,比如ps aux | grep guest。
我正在等待它改变。有什么方法可以像 tail 命令对文件执行的操作一样吗?
最大
【问题讨论】:
我想关注特定命令的输出,比如ps aux | grep guest。
我正在等待它改变。有什么方法可以像 tail 命令对文件执行的操作一样吗?
最大
【问题讨论】:
您正在寻找:
watch "ps aux | grep guest"
【讨论】:
--interval 标志。
-n seconds。来自手册页:watch runs command repeatedly, displaying its output and errors (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds; use -n or --interval to specify a different interval. Normally, this interval is interpreted as the amout of time between the completion of one run of command and the beginning of the next run. However, with the -p or --precise option, you can make watch attempt to run command every interval seconds.
watch ps 如果您没有太多进程(可以同时监控每个进程)也可以正常工作。