Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

watch command in Linux with Examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

watch command in Linux is used to execute a program periodically, showing output in fullscreen. This command will run the specified command in the argument repeatedly by showing its output and errors. By default, the specified command will run every 2 seconds and watch will run until interrupted.

Syntax:

watch [options] command

Options:

  • -d, –differences: This option highlights the differences between successive updates. The options will be going to read the optional argument which changes highlight to be permanent, allowing the user to see what has changed at least once since the first iteration.

    Example:

    watch -d  free -m

  • -n, –interval seconds: This option will specify update interval. The command will not be going to allow quicker than the 0.1-second interval, in which the smaller values are getting converted.

    Example:

    watch -n 1 free -m

  • -p, –precise: This option make watch attempt to run command every interval seconds.

    Example:

    watch -p free -m

  • -t, –no-title : This option is used to turn off the header showing the interval, command, and the current time at the top of the display. It will also turn off the following blank line.
    .

    Example :

    watch -t free -m

  • -b, –beep: This option will give beep if the command has a non-zero exit.

    Example:

    watch -b free -m

  • -e, –errexit : This option will freeze the updates on command error, and exit after a key press.

    Example:

    watch -e free -m

  • -g, –chgexit : This option will exit when the output of command changes.
  • -c, –color : This option interprets ANSI color and style sequences.
  • -x, –exec : This option command given to sh -c which means that you may need to use extra quoting just to get the desired effect.
  • watch -h : This option will show the help message and exit.
    watch -h

  • watch -v : This option will display the version information and exit.
    watch -v

My Personal Notes arrow_drop_up
Last Updated : 27 May, 2019
Like Article
Save Article
Similar Reads