Skip to content

watch Command Cheat Sheet

watch executes a program periodically, showing output fullscreen.


Synopsis

watch [options] command

Basic Usage

Default (Every 2 seconds)

watch date

Set Refresh Interval (-n)

Run every 0.1 seconds (fast).

watch -n 0.1 "ls -l | wc -l"

Monitoring Changes (-d)

Highlight the differences between successive updates.

watch -d free -m
Great for seeing exactly what memory values are changing.

Cumulative Highlighting (-d=cumulative)

Keep highlights permanently (sticky).

watch -d=cumulative uptime

Clean Output

Remove Hardware Header (-t)

Hide the top header (time, command, interval).

watch -t ls -l

Color Support (-c)

Understand ANSI color codes (if the command produces them).

watch -c "ls --color=always"

Troubleshooting Pipes

Wrap complex commands in quotes.

watch "ps aux | grep nginx | wc -l"

Common Use Cases

Monitor Disk Space and Inodes

watch -n 5 "df -h; df -i"

Watch Network Connections

watch -n 1 "netstat -ant | grep ESTABLISHED | wc -l"

Monitor a File Download Size

watch -n 1 "ls -lh largefile.iso"

Notes

  • Exit: Press Ctrl+C to stop.
  • Precision: watch is not real-time; it has overhead. Use specialized tools (top, iotop) for precision monitoring.