Linux -- watch command usage

Source: Internet
Author: User

Linux -- watch command use 1. watch command introduction www.2cto.com watch [options] commandThe watch program executes a given command at regular inter-vals; the default is every two seconds. the command is passed to the shell (so be sure to quote or escape any special characters), and the results are displayed in a full-screen mode, so you can observe the output conveniently and see what has changed. for example, run repeatedly at intervals. A command. The default interval is 2 seconds. The command to be run is directly transmitted to shell (note that special characters are referenced and escaped ). The result is displayed in full screen mode, so that you can easily observe the changes. For example, watch-n 60 date executes the date command once a minute, sort of a poor man's clock. type ^ C to exit. run the date command once every minute and enter ^ C to exit. Www.2cto.com 2. useful options common options-n seconds Set the time between executions, in seconds. set the runtime interval, in seconds-d Highlight differences in the output, to emphasize what has changed from one execution to the next. different highlighted outputs emphasize different executions. 3. watch manual NAME watch-execute a program periodically, showing output fullscreen watch-regular program execution, output full screen SYNOPSIS watch [-dhvt] [-n <seconds>] [-- differences [= cumulative] [-- help] [-- interval = <seconds>] [-- no-title] [-- version] <command> DESCRIPTION watch runs command repeatedly, displaying its output (the first screen-full ). this allows you to watch the program output change over time. by default, th E program is run every 2 seconds; use-n or -- interval to specify a different interval. Monitor repeated running commands and display the output (full screen ). Let you monitor program output changes. The default program runs once every 2 seconds. Use-n or -- interval to specify the-d or -- differences flag will highlight The differences between successive updates. the -- differences [= cumulative] option makes highlighting "sticky", presenting a running display of all positions that have ever changed. the-t or -- no-title option turns off the header showing the interval, command, and current time at the top of the display, as well as Following blank line.-d or -- differences will highlight new content. The -- cumulative option enables the highlighted display to show all the modifications in the running process. -T or -- no-title option disable the header display and only display blank rows. Watch will run until interrupted. watch will continue to run, knowing the interruption. NOTE Note that command is given to "sh-c" which means that you may need to use extra quoting to get the desired effect. note that you need to apply the command "sh-c" to achieve the expected effect. Note that POSIX option processing is used (I. e ., option processing stops at the first non-option argument ). this means that flags after command don't get interpreted by watch itself. note that using the POSIX option (the option will stop at the first non-option parameter) means you cannot set the interval after the command. Www.2cto.com EXAMPLES To watch for mail, you might do view mail watch-n 60 from To watch the contents of a directory change, you can use To view directory changes: watch-d ls-l If you're only interested in files owned by user joe, you might use wants to find the user's file, is the following command watch-d 'LS-l | fgrep joe 'To see the effects of quoting, try these out use watch echo to view quotation marks $ watch echo '$ 'Watch echo "'" '$' "'" to end

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.