linux下的watch命令使用小结


linux下的watch命令使用小结
 
关于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
 
watch -- 监测命令的运行结果
 
watch是一个非常实用的命令,基本所有的Linux发行版都带有这个小工具,如同名字一样,watch可以帮你监测一个命令的运行结果,省得你一遍遍的手动运行。
 
在Linux下,watch是周期性的执行下个程序,并全屏显示执行结果。
 
-d, --differences[=cumulative] 高亮显示变动
-n, --interval= 周期(秒)
 
如:watch -n 1 -d netstat -ant
其它操作:
切换终端: Ctrl+x
退出watch:Ctrl+g
 
watch -n 1 -d 'pstree|grep http' 每隔一秒高亮显示http链接数的变化情况。 后面接的命令若带有管道符,需要加''将命令区域归整。
 
在查看攻击时,经常使用的方式有如下:
实时查看模拟攻击客户机建立起来的连接数,使用
watch 'netstat -an | grep:21 | \ grep<模拟攻击客户机的IP>| wc -l'   
 
查看模拟攻击客户机被 DROP 的数据包数。
 
watch 'iptables -L -n -v | \grep<模拟攻击客户机的IP>'   
 
谢谢TTPLAY~

相关内容

    暂无相关文章