watch
Explanation
The watch command runs a specified command repeatedly and displays its output and errors (the first screenfull). This allows you to watch the program output change over time. By default, the command is run every 2 seconds.
Basic Syntax
watch [OPTION]... COMMAND
Common Flags and Options
| Flag | Description |
|---|---|
-n, --interval=SECS | Specify update interval in seconds. |
-d, --differences[=PERMANENT] | Highlight the differences between successive updates. |
-t, --no-title | Turn off the header showing the interval, command, and current time. |
Real-world Examples
-
Monitor disk space usage, updating every 2 seconds:
watch df -h -
Watch the output of
lsto see a file being downloaded:watch -n 1 ls -l largefile.iso -
Monitor memory usage and highlight changes:
watch -d free -m