Linux watch命令详解


watch可以帮你监测一个命令的运行结果,来监测你想要的一切命令的结果变化

常见命令参数

Usage: watch [-dhntv] [--differences[=cumulative]] [--help] [--interval=<n>] [--no-title] [--version] <command>
-d, --differences[=cumulative] highlight changes between updates
(cumulative means highlighting is cumulative)
-h, --help print a summary of the options
-n, --interval=<seconds> seconds to wait between updates
-v, --version print the version number
-t, --no-title turns off showing the header

常见命令展示

每隔一秒高亮显示网络链接数的变化情况

watch -n 1 -d netstat -ant 【-n 设置间隔,-d,difference,高亮显示不同】

watch -d 'ls /home/omd' 【-d 高亮显示】

watch -t 'ls /home/omd' 【-t会关闭watch命令在顶部的时间间隔】

说明: 切换终端: Ctrl+x 退出watch:Ctrl+g

每隔一秒高亮显示http链接数的变化情况

watch -n 1 -d 'pstree|grep http'

实时查看模拟攻击客户机建立起来的连接数

watch -n 1 -d 'netstat -an | grep "21" | egrep "192.168.25.100"| wc -l'

监测当前目录中 scf' 的文件的变化

watch -d 'ls -l|grep scf'

10秒一次输出系统的平均负载

watch -n 1 -d "uptime"


作者:​​小a玖拾柒​​​ ​

-------------------------------------------

个性签名: 所有的事情到最後都是好的,如果不好,那說明事情還沒有到最後~

本文版权归作者【​​小a玖拾柒​​​】,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利!