Basic usage
watch command
watch ls -la
Update interval
watch -n 2 command
watch -n 5 df -h
watch -n 0.1 command
Highlight differences
watch -d command
watch --differences command
Cumulative highlights
watch -d=cumulative command
Precise interval
watch -p -n 1 command
No title
watch -t command
Exit on change
watch -g command
Common use cases
Monitor disk space
watch -n 5 df -h
Watch processes
watch -n 1 'ps aux | grep process'
watch -n 1 'ps aux --sort=-%mem | head -20'
Monitor network
watch -n 1 ss -tuln
watch -n 1 'netstat -tuln | grep LISTEN'
System resources
watch -n 1 free -h
watch -n 1 'cat /proc/loadavg'
File changes
watch -n 1 ls -lh file.txt
watch -n 1 'wc -l logfile.log'
Docker containers
watch -n 2 docker ps
watch -n 1 'docker stats --no-stream'
Git status
watch -n 5 git status
watch -n 10 'git log --oneline -5'
Kubernetes
watch -n 2 kubectl get pods
watch -n 1 'kubectl top nodes'
Advanced examples
Multiple commands
watch 'uptime; free -h; df -h /'
With pipes
watch 'ps aux | grep nginx | wc -l'
Colored output
watch --color 'ls --color=always'
Beep on change
watch -b -n 1 command
Monitor log file
watch -n 1 'tail -20 /var/log/app.log'
Comparison with alternatives
watch -n 1 command
while true; do clear; command; sleep 1; done
tail -f file.log
Tips
watch 'ps aux | grep nginx'
while sleep 1; do clear; date; ps aux | grep nginx; done
watch -n 60 'date >> /tmp/watch.log; df -h >> /tmp/watch.log'