Watch Command Basics
What is the Watch Command?
The watch
command in Linux is a powerful utility that allows you to execute a command periodically and display its output. It's particularly useful for monitoring system changes, tracking process status, or observing dynamic information in real-time.
Basic Syntax
The basic syntax of the watch
command is:
watch [options] command
Core Functionality
The primary purpose of watch
is to:
- Run a specified command at regular intervals
- Display the command's output in a full-screen mode
- Automatically update the output
Key Features
graph TD
A[Watch Command] --> B[Periodic Execution]
A --> C[Real-time Monitoring]
A --> D[Customizable Interval]
A --> E[Highlight Changes]
Common Options
Option |
Description |
Example |
-n |
Set update interval (seconds) |
watch -n 2 ls |
-d |
Highlight differences between updates |
watch -d free |
-t |
Turn off the header |
watch -t date |
Simple Example
## Monitor disk usage every 3 seconds
watch df -h
Use Cases
- System Monitoring
- Network Status Tracking
- Process Observation
- Resource Utilization Checking
LabEx recommends practicing watch
commands to improve your Linux system administration skills.