Linux watch Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux watch Guide
Complete beginner-friendly guide to watch on Linux, covering Arch Linux, CachyOS, and other distributions including monitoring commands, periodic execution, and real-time monitoring.
Table of Contents
Understanding watch
What is watch?
watch executes command periodically.
Uses:
- Monitor commands: Watch command output
- Periodic execution: Run commands repeatedly
- Real-time monitoring: Monitor in real-time
- System monitoring: Monitor system status
Why it matters:
- Monitoring: Monitor command output
- Real-time updates: See updates in real-time
- System observation: Observe system changes
watch Basics
Watch Command
Basic usage:
# Watch command (default: 2 seconds)
watch command
# Updates every 2 seconds
Custom Interval
Set interval:
# Custom interval (5 seconds)
watch -n 5 command
# -n = interval (seconds)
Monitoring Commands
System Monitoring
Monitor system:
# Monitor processes
watch -n 1 'ps aux | head -20'
# Monitor disk usage
watch -n 2 df -h
# Monitor memory
watch -n 1 free -h
Highlight Changes
Show differences:
# Highlight changes
watch -d command
# -d = differences (highlights changes)
⏱ Update Intervals
Fast Updates
Quick updates:
# Update every second
watch -n 1 command
# Very fast updates
Slow Updates
Slower updates:
# Update every 10 seconds
watch -n 10 command
# Less frequent updates
Troubleshooting
watch Not Found
Check installation:
# Check watch
which watch
# Install if missing
sudo pacman -S procps-ng
Summary
This guide covered watch usage, command monitoring, and periodic execution for Arch Linux, CachyOS, and other distributions.
Next Steps
- htop Guide - Interactive monitoring
- System Monitoring - System monitoring
- watch Documentation:
man watch
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.