手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

watch:监测命令运行

[日期:2011-06-06] 来源:bentutu.com  作者:tuhaihe [字体:大 中 小]

今日,给大家介绍命令watch,使用该命令可以检测终端运行命令的运行情况。

该命令可以用来监测程序输出结果,默认2秒间隔运行,可以使用参数-n 或 -interval 来指定不同的间隔时间。

基本使用方法watch  ”需要监测的运行命令”

上文讲过,watch默认2秒间隔运行一次

可选参数我们基本常用的参数如下:

-n set the interval in seconds.

-d flag will highlight the differences between successive updates.

-b option causes the command to beep if it has a non-zero exit.

-e cause watch to exit on an error from the program running.

使用举例#1,高亮显示指定目录的内容

watch -d  "ls -alrt /tmp/"#2,终端显示时钟,每1秒更新一次

watch -t -n 1 "date"#3,每隔10秒钟查看占用CPU资源最多的进程

watch 'ps -eo pcpu,pid,user,args | sort -k 1 -n -r | head -10'

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款