Linux 常用命令之 watch

Linux 常用命令之 watch

目录

Linux 常用命令之 watch

常见命令参数说明

案例展示

1.纯净的watch + 命令

2.watch+常用参数


​​​​​​​

 
watch可以帮你实时的监测一个命令的运行结果及命令的结果变化,在运维过程中,是一个比较实用方便的工具。
 
使用语法如下:
Usage: watch  [-dhntv] [--differences[=cumulative]] [--help] [--interval=] [--no-title] [--version] < command >
 
 

常见命令参数说明

命令选项
英文说明
中文描述
-d, --differences [permanent]
Highlight the differences between successive updates.  Option will read optional argument that changes highlight to be permanent, allowing to see what has changed at least once since first iteration.
高显示命令结果的差异部分
-t, --no-title
Turn off the header showing the interval, command, and current time at the top of the display, as well as the following blank line.
不在页面的头部展示花哨的部分,显示的内容全是干货,是命令结果
-n, --interval seconds
Specify update interval.  The command will not allow quicker than 0.1 second interval, in which the smaller values are converted.
指定命令的刷新间隔时间,单凭是 秒
-h,-v
 
命令帮助和查询watch版本
 
 

案例展示

 

1.纯净的watch + 命令

可以看出,默认是2s刷新一次命令的运行结果的,然后显示窗口的头部有时间和日期及命令的说明等花哨的东西

[root@localhost ~]# watch 'date +"%Y年%m月%d日 %H:%M:%S %A  本年度:第 %U 周,第 %j 天"'
Every 2.0s: date +"%Y年%m月%d日 %H:%M:%S %A  本年度:第 %U 周,第 %j 天"                                                                                                                                                     Sun May 10 11:57:30 2020

2020年05月10日 11:57:30 星期日  本年度:第 19 周,第 131 天

 

2.watch+常用参数

说明:会高亮显示结果变化的部分,并且不会显示头部的花哨说明,以下命令会3秒更新 一次结果
[root@localhost ~]# watch  -d -t -n 3 'date +"%Y年%m月%d日 %H:%M:%S %A  本年度:第 %U 周,第 %j 天"'

2020年05月10日 12:02:01 星期日  本年度:第 19 周,第 131 天

 

你可能感兴趣的:(Linux/Shell,linux,运维,监控类,扫描测试工具)