Linux Command: watch
Execute a program periodically and show output
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.
Syntax
watch [OPTION]... COMMANDKey Options
-n Nโ Update every N seconds (default 2)-dโ Highlight differences between updates-tโ Hide the header-gโ Exit when output changes-eโ Exit on error
Examples
Monitor disk space
watch -n 10 df -hMonitor connections
watch -n 1 "ss -s"Highlight changes
watch -d "ls -la /var/log/"Pro Tips
- Use quotes for pipes: watch "command | grep filter". Without quotes, the pipe is interpreted by the current shell.
- -d highlights what changed between refreshes. Very useful for spotting changes in large outputs.
- Commands using colors or terminal features may display poorly. Use --color flag or pipe through col -b if needed.
Learn more: Full watch reference โ