watch 是一个非常实用的命令,基本所有的 Linux 发行版都带有这个小工具,如同名字一样,watch
可以帮你监测一个命令的运行结果,省得你一遍遍的手动运行。
直接在 watch 后面接你想运行的命令,watch
就会帮你重复运行,并把每次的结果都更新在屏幕上。
默认 watch 会以 2s 的间隔重复运行命令,你也可以用 -n
参数指定时间间隔~
还有一个实用的参数是 -d,这样 watch 会帮你高亮显示变化的区域,这样更加一目了然了~
Ctrl+c
就可以退出~
你可以拿他来监测你想要的一切命令的结果变化,比如 tail 一个 log 文件,ls
监测某个文件的大小变化,看你的想象力了~
FreeBSD和Linux下watch命令的不同

在Linux下,watch是周期性的执行下个程序,并全屏显示执行结果。
-d, --differences[=cumulative] 
     高亮显示变动
-n, --interval=              周期(秒)
如:watch -n 1 -d netstat
-ant
而在FreeBSD下的watch命令是查看其它用户的正在运行的操作,watch允许你偷看其它terminal正在做什么,该命令只能让超级用户使用。
如何运行watch:
[root@pdc
conf]# who
root             ttyp0    Oct  2 21:48 (192.168.x.x)
root    
        ttyp1    Oct  2 22:25 (192.168.x.x)
xxhui            ttyp3    Oct  2
23:48 (192.168.x.x)
[root@pdc conf]# watch
ttyp3

watch命令详解
NAME
       watch - execute a program
periodically, showing output fullscreen
SYNOPSIS
      
watch  [-dhvt]  [-n ] [--differences[=cumulative]] [--help] [--interval=]
[--no-title] [--version]
DESCRIPTION
       watch runs command
repeatedly, displaying its output  (the  first  screenfull). 
This  allows  you  to watch the program output change over time.  By default,
the program is  run every 2 seconds; use -n or --interval to specify a different
interval.
       The -d
or  --differences  flag  will  highlight  the  differences  between  successive
updates.   The  --cumulative  option makes highlighting "sticky", presenting a
running display of all positions that have ever changed.  The -t
or  --no-title  option  turns off  the header showing the interval, command, and
current time at the top of the display, as well as the following blank line.
watch will run until interrupted.
NOTE
       Note that command is
given to "sh -c" which means that you may need to use extra quoting to get the
desired effect.
       Note  that POSIX option processing is used (i.e.,
option processing stops at the first non-option argument).  This means that
flags after command don't  get  interpreted  by watch
itself.
EXAMPLES
       To watch for mail, you might do:    watch
-n 60 from
       To watch the contents of a directory change, you could
use:   watch -d ls -l
       If youre only interested in files owned by user
joe, you might use: watch -d 'ls -l | fgrep joe'
       You can
watch for your administrator to install the latest kernel with:  watch uname
-r  (Just kidding.)呵呵
BUGS
       Upon terminal resize, the screen
will not be correctly repainted until the next scheduled update.  All
--differences highlighting is lost on that update as well.
      
Non-printing characters are stripped from program output.  Use "cat -v" as part
of the command pipeline if you want to see them.

转载于:https://www.cnblogs.com/xjx-user/archive/2013/05/02/3055516.html

Linux的watch命令 -- 实时监测命令的运行结果相关推荐

  1. Linux的watch命令--实时监测命令的运行结果

    watch 是一个非常实用的命令,基本所有的 Linux 发行版都带有这个小工具,如同名字一样,watch 可以帮你监测一个命令的运行结果,省得你一遍遍的手动运行.直接在 watch 后面接你想运行的 ...

  2. [收藏学习]Linux的实时监测命令

    十八.  和系统运行状况相关的Shell命令:    1. Linux的实时监测命令(watch):     watch 是一个非常实用的命令,可以帮你实时监测一个命令的运行结果,省得一遍又一遍的手动 ...

  3. 4)lsof linux命令,***Linux命令实时监测系统(top,htop,iotop,lsof,tcpdump,netstat,vmstat,iostat)...

    摘要:本文总结了8个非常实用的Linux命令行性能监测工具,这些命令支持所有的Linux系统,不仅可以用于监控系统,还可以发现导致性能问题的原因所在. 对每个系统/网络管理员来说,每天监测Linux系 ...

  4. Linux的实时监测命令(watch)

    watch 是一个非常实用的命令,可以帮你实时监测一个命令的运行结果,省得一遍又一遍的手动运行.该命令最为常用的两个选项是-d和-n,其中-n表示间隔多少秒执行一次"command" ...

  5. linux 网卡流量脚本,实时查看Linux网卡流量的shell脚本分享(图文)

    实时查看linux下的网卡流量,脚本内容如下: 复制代码 代码示例: #!/bin/bash #filename interface.sh eth=eth0 RXpre=$(ifconfig ${et ...

  6. 【Linux学习笔记】 -- 基本Shell命令

    常见的目录名均基于文件系统层级标准(filesystem hierarchy standard,FHS) Linux的四个部分: 1 Linux内核:控制所有硬软件,必要时分配硬件根据需要执行软件 系 ...

  7. 常用的深度学习的linux代码(1.实时监测GPU情况2.当前正常使用的GPU情况3.杀掉特定某个进程4.杀掉特定某个进程)

    1.实时监测GPU情况 watch -n 1 nvidia-smi 2.当前正常使用的GPU情况 nvidia-smi 3.查看进程 ps -ef 杀掉特定某个进程 kill -9 PID 4.lin ...

  8. linux 必须掌握的60个命令

    Linux必学的60个命令 http://blog.csdn.net/ustc_dylan/article/details/4152501 Linux提供了大量的命令,利用它可以有效地完成大量的工 作 ...

  9. linux 阶段作业领导者,Linux入职基础-5.22_命令ps显示进程状态(应用实战6)

    命令ps显示进程状态(应用实战6) 简介: 由于一个应用程序可能需要启动多个进程,所以在同等情况下,进程的数量要比程序多.要对进程进行监测和控制,首先必须要了解当前进程的情况,而 ps 命令就是非常强 ...

最新文章

  1. 浏览器崩溃时提示137错误
  2. php输出0到5之间到数,php如何实现输出链表倒数第k个结点(代码实例)
  3. CTF刷题网站汇总(包括本地可以自己搭建的)(1)
  4. Elasticsearch环境搭建和介绍(Windows)
  5. STL源码剖析 5中迭代器型别
  6. android studio有错误,清单合并失败,Android Studio中出现多个错误
  7. 使用Qt设计师文件的3种方式
  8. 【Elasticsearch】Kibana优化过程(Optimize)过长或无法结束的解决方案
  9. YAML_12 批量创建用户,分别设置用户组
  10. C语言性能优化书籍,Android应用性能优化 (埃尔韦) 中文PDF扫描版
  11. MySQL单表删除重复列SQL语句
  12. Windows 创建 Redis 和 zookeeper 系统服务
  13. Ubuntu 更改挂载磁盘权限
  14. JavaScript之this,new,delete,call,apply
  15. eclipse svn设置忽略文件
  16. 我使用的网址--Hadoop
  17. WebSocket消息推送(实现进行聊天)和WebSocket简介
  18. shell - 常识
  19. VS2017使用github
  20. 酒店opera系统服务器故障,【干货】酒店人必学的Opera系统中英讲解(值得收藏)...

热门文章

  1. 清华大学自主研究的计算机,清华大学人工智能研究院成立基础理论研究中心,朱军教授任中心主任...
  2. qt5使用触屏 偶尔没响应_戴着手套玩手机!你试过吗?触屏灵敏又保暖,冬天再也不冻手~...
  3. linux怎么初始命令,linux 第二季 初始linux 目录以及初始命令
  4. java帧结构_Java虚拟机运行时栈帧结构--《深入理解Java虚拟机》学习笔记及个人理解(二)...
  5. spark写出分布式的训练算法_Spark0.9分布式运行MLlib的线性回归算法
  6. jmeter 加密解密_AES加密的安全问题
  7. 控制只读_用Python控制硬件44-四位半万用表UT61E
  8. 907计算机专业基础与408相比,2018年北京大学信息科学技术学院907计算机专业基础之计算机操作系统考研强化五套模拟题...
  9. linux-headers,如何升级linux-headers-generic?
  10. 通讯录通过id找邮箱和手机