Open In App

watch command in Linux with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

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


Last Updated : 27 May, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads