Watch is a very useful command, basically all Linux distributions with this gadget, like a 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.
-D or--differences use the-D or--differences option Watch to 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
1 -D netstat-ant
Description
Other operations:
Switch Terminal: ctrl+x
Exit Watch:ctrl+c
Example 2: Highlighting changes in the number of HTTP links every second
Command:
1 ' 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:
' Netstat-an | grep:21 | \ grep< analog attack client ip>| wc-l '
Description
Example 4: Monitoring changes in SCF ' files in the current directory
Command:
' Ls-l|grep SCF '
Example 5: Average load of one output system in 10 seconds
Command:
Ten ' Cat/proc/loadavg '
Linux commands-Real-time monitoring commands: Watch