大龙的博客

常用链接

统计

最新评论

定时执行命令,观察输出

如果要持续执行一个命令,然后观察输出的话,我们一遍一遍的按上回车,然后看着输出。watch命令可以很好的实现这个功能。比如,要监控linux的连接数:

  1. watch -n 2 -d 'netstat -est | grep est'  
输出:
  1. Every 2.0s: netstat -est | grep est                                                                                              Mon Mar 19 10:46:03 2012  
  2.   
  3.     12784 connections established  
  4.     556 packets rejects in established connections because of timestamp  
  5.     2015 congestion windows fully recovered without slow start  
  6.     9672 congestion windows partially recovered using Hoe heuristic  
  7.     20983 congestion windows recovered without slow start by DSACK  
  8.     22010 congestion windows recovered without slow start after partial ack  
-n指定命令执行的时间间隔,-d高亮显示连续两侧输出的差别,为了便于观察,最后一个参数是要执行的命令。

posted on 2013-02-18 21:16 大龙 阅读(415) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理