341Currently online
112Today's Reading
16Share Today
Multilingual display

watch command usage (linux monitoring status)

2018-04-24 11:12:51

You can use the watch command to set the execution interval to repeatedly interval a command or combine commands to view certain status information.


linux system


The command is executed at intervals and the command output is monitored. For example, watch -n 1 'ls'-n indicates the number of seconds at which the command is executed. For example, the ls command is executed once for 1s.


Related content Illegal climbing taken from experience


Execute composite commands. Sometimes the commands that refresh at intervals are composite commands, which can be implemented using -t. For example, watch -n 1 -t 'ps -ef | grep ps' The command is used to monitor the running processes that contain the ps character every second. The two commands are separated by |. In addition, -t closes the header.


You can use watch --help to find out more about watch.

Matters needing attention

The commands executed at intervals must be enclosed in double quotation marks (")