๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

๐Ÿ’ก Logging & Monitoring September 22, 2026 9

Linux Command: watch

Execute a program periodically and show output

Terminal โ€” Logging & Monitoring
Command
$ watch -n 10 df -h

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]... COMMAND

Key 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 -h

Monitor 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 โ†’

Share this tip