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

 

常见命令展示

# 每隔一秒高亮显示网络链接数的变化情况
# -n 设置间隔,-d,difference,高亮显示不同
watch -n 1 -d netstat -ant

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

# -t会关闭watch命令在顶部的时间间隔
watch -t 'ls /home/omd'
 
# 切换终端: 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 10 -d "uptime"

# 2秒一次 输出xxx信息
watch -n 2 'ps -ef |grep xxx'

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值