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

常見命令展示

每隔一秒高亮顯示網絡鏈接數的變化情況

watch -n 1 -d netstat -ant 【-n 設置間隔,-d,difference,高亮顯示不同】

   watch -d 'ls /home/omd'       【-d 高亮顯示】

   watch -t 'ls /home/omd'       【-t會關閉watch命令在頂部的時間間隔】

說明: 切換終端: 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 1 -d "uptime"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM