Linux 常用命令之 watch

Linux 常用命令之 watch

目錄

Linux 常用命令之 watch

常見命令參數說明

案例展示

1.純淨的watch + 命令

2.watch+常用參數


​​​​​​​

 
watch可以幫你實時的監測一個命令的運行結果及命令的結果變化,在運維過程中,是一個比較實用方便的工具。
 
使用語法如下:
Usage: watch [-dhntv] [--differences[=cumulative]] [--help] [--interval=<n>] [--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 天

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章