Many Linux users write small scripts to monitor system state — CPU usage, disk space, open connections, and more.
But there is a much simpler tool built into most Linux systems: watch.
It allows you to run any command repeatedly and see the output update in real time.
Basic usage
The syntax is simple:
watch command
By default, the command runs every 2 seconds.
Example: monitoring the mail queue
watch mailq
This refreshes the list of outgoing messages every two seconds so you can see the mail queue shrink or grow in real time.
Example: watching network connections
watch ss -tuln
This is useful when debugging network services or checking if a port becomes active.
Example: monitoring processes
watch "ps aux | grep nginx"
This lets you observe whether a process starts, stops, or changes.
Changing the interval
You can change the refresh interval with -n.
watch -n 1 mailq
This runs the command every 1 second.
Highlighting differences
One of the most useful options is -d, which highlights changes between updates.
watch -d netstat -tuln
This makes it much easier to see what changed since the previous refresh.
Conclusion
watch is a small but powerful tool.
It can turn almost any command into a simple real-time monitoring dashboard without writing scripts.
Sometimes the best tools in Linux are also the simplest.
Top comments (0)