Linux using the example of the watch command

  
                

Linux watch is a monitoring command, used to monitor the execution of the command, and periodically execute the program, is a more common command, the following small series will give you a detailed introduction to the use of the Linux watch command.

1. Command format:

watch[parameter][command]

2. Command function:

The output of the command can be output to the standard output device, which is mostly used to execute the command/timed execution command periodically

3. Command parameters:

-n or --interval watch By default, the program runs every 2 seconds. You can use -n or -interval to specify the interval time.

-d or --differences The watch will highlight the changed area with the -d or --differences option. The -d=cumulative option highlights the changed places (regardless of the recent changes).

-t or -no-title will turn off the watch command at the top of the interval, command, and current time output.

-h, --help View help documentation

4. Example:

Instance 1:

Command: Highlight the number of network links every second.

The code is as follows:

watch - n 1 -d netstat -ant

Description:

Other operations:

Switch terminal: Ctrl+x

Exit watch:Ctrl+g

Instance 2: Highlighting changes in the number of http links every second

Command:

The code is as follows:

watch -n 1 -d &lsquo ;pstree

Copyright © Windows knowledge All Rights Reserved