Just thought I should do a quick post about a command that is extremely useful but often forgotten and that command is “watch”. Syntax of this command is:


[-n SEC] [-t] PROG ARGS

where “n” is the interval in seconds (2 by default).

This command is used as a wrapper, to constantly update results from another command, at a particular frequency. That makes it very useful for monitoring a particular activity for troubleshooting/investigations.

A few months back, I used this command during an investigation into a NTP-related question from a customer. The command used in that case was:

watch “ntpq -p localhost”

Time Query with four individual VMware NTP

If I want to constantly monitor NIC statistics, I can use:

watch “ethtool -S vmnic5”

Watch - Ethtool

Another example is while copying large files between datastores. If you want to keep an eye on datastore usage, just in case it fills up, you can use:

watch “df -h”

Watch - df

while the files copy across. This is much more accurate and real-time than the GUI.

I am sure there will be many other uses that you can find for it. This post is just a quick reminder to those who might have forgotten, how useful this command is.

Hope this helps!