Watch is a very useful command, basically all Linux distributions with this gadget, like the name, watch can help you monitor the results of a command, save you to manually run over and over again. Under Linux, watch is the periodic execution of the next program, and full-screen display of the execution results. You can use him to monitor everything you want. The result of the command changes, such as tail a log file, ls monitoring a file size changes, see your imagination!
1. Command format:?
watch[parameters [command]
2. Command function:
The output of the command can be output to a standard output device, which is used for periodic execution of commands/timed execution commands
3. Command parameters:
-N or--interval watch defaults to run the program every 2 seconds, you can use-N or-interval to specify the time interval.
#p # page Header #e#-d or--differences with the-D or--differences option Watch will highlight the changed area. The-d=cumulative option highlights the changes that have been made (regardless of the recent change).
The-T or-no-title will turn off the watch command at the top of the interval, command, output of the current time.
-H,--help view Help documentation
4. Usage examples:
Example 1:
Command: Highlight the changes in the number of network links every second
Watch-n 1-d Netstat-ant
Description: #p # page Title #e#
Other operations:
Switch Terminal: ctrl+x
Exit Watch:ctrl+g
Example 2: Highlighting changes in the number of HTTP links every second
Command:
Watch-n 1-d ' Pstree|grep http '
Description
Highlights the change in the number of HTTP links every second. If the command is followed by a pipe character, the command area must be "organised".
Example 3: Real-time view of the number of connections built up by simulated attack clients
Command:
Watch ' Netstat-an | grep:21 | \ grep< Impersonation attack client's ip>| Wc-l '
#p # Page Title #e# Description:
Example 4: Monitoring changes in SCF ' files in the current directory
Command:
Watch-d ' Ls-l|grep scf '
Example 5: Average load of one output system in 10 seconds
Command:
Watch-n ' Cat/proc/loadavg '
Reproduced in: http://www.itxuexiwang.com/a/liunxjishu/2016/0306/246.html?1457358582
One Linux command per day: Watch command