linux watch命令

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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值