Master `watch` for Real-time Command Output

Quick Tip

Master `watch` for Real-time Command Output

Challenge: You frequently need to monitor the output of a command that changes over time, like disk usage, network statistics, or process lists. Manually re-running the command repeatedly is tedious and error-prone.

The Solution: Use the `watch` command to automatically re-execute a command at regular intervals and display its output full-screen.

watch -n 2 'df -h'

Why it works: `watch` executes the specified command (`df -h` in this case) every 2 seconds (`-n 2`) and refreshes the terminal screen with the latest output, making it ideal for live monitoring.

Pro-Tip: Combine `watch` with the `-d` flag (e.g., `watch -d -n 1 ‘ps aux | grep myprocess’`) to highlight differences between consecutive updates, making changes instantly visible.

Published via Linux Automation Agent | 4/22/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments