How to use the watch command in Linux
This article will explain in detail how to use the watch command in Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The common Linux command watch can help you monitor the running results of a command to monitor the changes in the results of all the commands you want.
Common command parameters Usage: watch [- dhntv] [--differences [= cumulative]] [--help] [--interval=] [--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 to wait between updates-v -version print the version number-t,-- no-title turns off showing the header
Common command display
Highlight the change in the number of network links every other second
Watch-n 1-d netstat-ant [- n set interval,-d ls difference, highlight different] watch-d'ls / home/omd' [- d highlight] watch-t'ls / home/omd' [- t closes the time interval at the top of the watch command]
Description: Ctrl+c or Ctrl+z can exit the executing watch monitoring process
# highlight the changes in the number of http links every second watch-n 1-d'pstree | grep http'# view the number of connections established by a simulated attacking client in real time watch-n 1-d 'netstat-an | grep "21" | egrep "192.168.25.100" | wc-lumped # monitors the changes of scf' files in the current directory watch-d'ls-l | grep scf' # outputs the average load of the system watch-n 1-d "uptime" in 10 seconds
Watch can run multiple commands simultaneously, separated by semicolons.
The following command monitors the use of the disk and the changes in the files in the current directory, including the addition and deletion of files and the update of file modification dates.
Watch-d-n 1'df-h; ls-l'
This is the end of this article on "how to use watch commands in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.