linux的watch命令非常有用,它可以定期的执行命令,并且满屏显示执行结果,全屏以外的内容可能就看不到了。
Usage: watch [-dhntv] [--differences[=cumulative]] [--help] [--interval=] [--no-title] [--version]
-d, --differences[=cumulative] highlight changes between updates(高亮显示跟上次结果不同的部分)
(cumulative means highlighting is cumulative)
-h, --help print a summary of the options
-n, --interval= seconds to wait between updates(指定更新的频率,以秒为单位)
-v, --version print the version number
-t, --no-title turns off showing the header(是否显示该命令的标题部分)
例子:
[root@m160-90 ~]# watch -d -n 10 ls -l
Every 10.0s: ls -l Wed Nov 26 12:33:46 2014(标题部分,如果-t的话就不显示该部分内容)
total 80
-rw------- 1 root root 1833 Jul 28 18:21 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Aug 5 13:42 Desktop
-rw-r--r-- 1 root root 45207 Jul 28 18:21 install.log
-rw-r--r-- 1 root root 5188 Jul 28 18:21 install.log.syslog
drwxr-xr-x 2 root root 4096 Jul 29 11:11 software
在另外一个窗口创建一个文件
[root@m160-90 ~]# touch yangsw
10秒周期结束,会刷新结果
Every 10.0s: ls -l Wed Nov 26 12:34:46 2014
total 80
-rw------- 1 root root 1833 Jul 28 18:21 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Aug 5 13:42 Desktop
-rw-r--r-- 1 root root 45207 Jul 28 18:21 install.log
-rw-r--r-- 1 root root 5188 Jul 28 18:21 install.log.syslog
drwxr-xr-x 2 root root 4096 Jul 29 11:11 software
-rw-r--r-- 1 root root 0 Nov 26 12:34 yangsw
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26613085/viewspace-1347383/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26613085/viewspace-1347383/