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.
watch [options] command
- -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.
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.
watch -n 1 free -m
- -p, –precise: This option make watch attempt to run command every interval seconds.
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.
watch -t free -m
- -b, –beep: This option will give beep if the command has a non-zero exit.
watch -b free -m
- -e, –errexit : This option will freeze the updates on command error, and exit after a key press.
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 -v : This option will display the version information and exit.
- w command in Linux with Examples
- gcc command in Linux with examples
- yes command in Linux with Examples
- more command in Linux with Examples
- col command in Linux with Examples
- ex command in Linux with examples
- look command in Linux with Examples
- atq command in linux with examples
- ln command in Linux with Examples
- cal command in Linux with Examples
- which command in Linux with examples
- bg command in Linux with Examples
- dc command in Linux with examples
- Cat command in Linux with examples
- dig Command in Linux with Examples
- cd command in Linux with Examples
- apt-get command in Linux with Examples
- mv command in Linux with examples
- fg command in Linux with examples
- let command in Linux with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.