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.
-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: Highlighting changes in the number of network links every second
Command:
Watch-n 1-d Netstat-ant
Description
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 '
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 '
Linux Common commands: Watch command