watch Command
Beginner Logging & Monitoring man(1)Execute a program periodically and show output
👁 12 views
📅 Updated: Mar 15, 2026
SYNTAX
watch [OPTION]... COMMAND
What Does watch Do?
watch executes a command repeatedly at a specified interval, displaying the output full-screen. It is perfect for monitoring changes in real time — disk usage, network connections, process lists, and any command output.
watch clears the screen and re-runs the command, showing the current time, interval, and command at the top. With -d, it highlights differences between updates.
watch is one of the simplest yet most useful monitoring tools. It turns any command into a real-time dashboard.
watch clears the screen and re-runs the command, showing the current time, interval, and command at the top. With -d, it highlights differences between updates.
watch is one of the simplest yet most useful monitoring tools. It turns any command into a real-time dashboard.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -n N | Update every N seconds (default 2) | watch -n 5 df -h |
| -d | Highlight differences between updates | watch -d free -h |
| -t | Hide the header | watch -t date |
| -g | Exit when output changes | watch -g ls /tmp/results/ |
| -e | Exit on error | watch -e ./check_service.sh |
Practical Examples
#1 Monitor disk space
Updates disk usage display every 10 seconds.
$ watch -n 10 df -h#2 Monitor connections
Shows network connection summary every second.
$ watch -n 1 "ss -s"#3 Highlight changes
Highlights file changes (new files, size changes).
$ watch -d "ls -la /var/log/"#4 Monitor process
Monitors nginx processes every second.
$ watch -n 1 "ps aux | grep nginx | grep -v grep"#5 Wait for file
Exits as soon as a file appears in the directory.
$ watch -g "ls /tmp/results/"#6 Monitor Docker
Shows running Docker containers, updating every 2 seconds.
$ watch -n 2 docker psTips & Best Practices
Quote complex commands: Use quotes for pipes: watch "command | grep filter". Without quotes, the pipe is interpreted by the current shell.
-d highlights changes: -d highlights what changed between refreshes. Very useful for spotting changes in large outputs.
Not all commands work: Commands using colors or terminal features may display poorly. Use --color flag or pipe through col -b if needed.
Frequently Asked Questions
How do I monitor a command continuously?
watch command runs it every 2 seconds. watch -n 5 command runs every 5 seconds.
How do I highlight changes?
watch -d command highlights differences between each refresh. Makes it easy to spot changes.
How do I stop watch?
Press Ctrl+C to exit. Or use -g to auto-exit when output changes.
Related Commands
More Logging & Monitoring Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →