Linux watch command

Posted at November 18, 2016 at 6:08 am by Jithin

Watch command is one of the most useful commands which mainly helps to keep an update on various system administrative processes. Today’s   Internet facility provides for the hackers to intrude into any system which is not well secured and regularly monitored for such attacks. These all can be monitored through the log files which are updated regularly. These regularly updated logs can be checked by executing the commands frequently. Since it is a tedious task to execute the commands repeatedly to view the logs. Commands such as head, tail, cat etc. which are used to read the files are usually used to check the logs. This is where the importance of watch commands comes into picture. The watch command allows you to  regularly repeat a command and produce the output. The burden of frequently executing the commands is avoided for the system administrators.


Watch Command

The syntax of watch command is:

  watch [options] command

The running period of watch command is by default 2 seconds. The running time cycle is counted between full execution of the command and starting of next execution.



1) The given example provides updated error/notices/warning every 2 seconds.

$ watch tail /var/log/messages

Every 2.0s: tail /var/log/messages                                  Thu Oct 13 07:31:16 2016

Oct 13 05:01:01 centos7 systemd: Started Session 87 of user root.

Oct 13 05:01:01 centos7 systemd: Starting Session 87 of user root.

Oct 13 05:29:09 centos7 kernel: conftest[30674]: segfault at 0 ip 0000000000400670 sp 00007ffdef8232a0 error 4 in conftest[400000+1000]

Oct 13 05:29:09 centos7 kernel: conftest[30697]: segfault at 0 ip 00007fc9ca9faad6 sp 00007ffce4c92bd8 error 4 in[7fc9ca8c8000+1b7000]

Oct 13 05:31:03 centos7 kernel: conftest[9223]: segfault at 0 ip 0000000000400670 sp 00007ffe3868d8e0 error 4 in conftest[400000+1000]

Oct 13 05:31:03 centos7 kernel: conftest[9246]: segfault at 0 ip 00007fccefa5bad6 sp 00007ffc02d18548 error 4 in[7fccef929000+1b7000]


2) The given example allows to check the usage of the disk where the result is update every 2 seconds.

$ watch df -h

Every 2.0s: df -h                                                                            Thu Oct 13 07:34:56 2016

Filesystem        Size      Used    Avail    Use%   Mounted on

/dev/vda3        47G      2.4G     42G      6%       /

devtmpfs          888M     0        888M   0%       /dev

tmpfs                897M     0        897M   0%       /dev/shm

tmpfs                897M   28M     869M   4%       /run

tmpfs                897M     0        897M   0%       /sys/fs/cgroup

/dev/vda1       477M  234M  215M  53%     /boot

tmpfs                180M     0        180M   0%       /run/user/0


3) The below given example updated uptime and load

$ watch uptime

Every 2.0s: uptime                                                                        Thu Oct 13 07:40:15 2016

07:40:15 up 3 days,  7:54,  1 user,  load average: 0.00, 0.01, 0.05


4) The below given example provides updated queue size of Exim

$ watch exim -bpc

Every 2.0s: uptime                                                                           Thu Oct 13 07:40:15 2016


Iteration delay

watch [-n <seconds>] command

This option allows to modify the running period of watch command. The given example shows how to run w command with a running period of 4 seconds.

watch –n 4 date

$ watch -n 4 w

Every 4.0s: w                                                                                                                Thu Oct 13 07:56:49 2016

07:56:49 up 3 days,  8:11,  1 user,  load average: 0.02, 0.04, 0.05

USER     TTY      FROM               LOGIN@   IDLE   JCPU   PCPU WHAT

root     pts/0    04:46   33.00s  0.09s  0.00s watch -n 4 w


Watch help

To get all the information regarding the watch command use the option –h or –help

$ watch –h [or –help]


Watch version

watch -v [–version]

This option allows to get the version of the watch.

$ watch -v

watch from procps-ng 3.3.10


If you need any further assistance please contact our support department.



0.00 avg. rating (0% score) - 0 votes

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply