watch(1)
Execute a program periodically, full screen, showing output differences.
Synopsis
watch [OPTION]... COMMANDDescription
Runs COMMAND repeatedly at specified intervals (default 2 seconds) and displays the full-screen output. Highlights changes between successive runs, making it useful for monitoring log files, system status, or long-running processes in real time.
Press 'q' to exit, 'Space' to refresh immediately, and 'e' to exit on command error. Useful alternatives to manually running commands with sleep loops.
Common options
| Flag | What it does |
|---|---|
-n SECONDS | Set interval between command executions (default 2 seconds) |
-d, --differences | Highlight differences between successive outputs |
-c, --color | Interpret ANSI color sequences in command output |
-t, --no-title | Turn off the header showing interval, command, and time |
-x, --exec | Pass COMMAND to exec instead of sh -c (avoids shell interpretation) |
-p, --precise | Run command every INTERVAL seconds exactly (compensates for command runtime) |
-e, --erase-repetitions | Remove repeated lines in output |
-w, --no-wrap | Turn off line wrapping (useful for wide output) |
Examples
Monitor a specific process every 1 second, highlighting changes
watch -n 1 'ps aux | grep myprocess'Watch disk usage with differences highlighted every 2 seconds
watch -d df -hCount established network connections every 5 seconds
watch -n 5 'netstat -an | grep ESTABLISHED | wc -l'Display date and uptime without the header, updating every 2 seconds
watch -t 'date && uptime'Monitor system journal with color support, 1-second updates
watch -c -n 1 'journalctl -n 20'Check git repository status every 10 seconds during a build
watch -n 10 'git status'Run command every 1 second precisely, compensating for execution time
watch -p -n 1 'echo $RANDOM'Monitor memory usage without shell interpretation, every 2 seconds
watch -x -n 2 free -h