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"