Linux Common commands: Watch command

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.