Not a lot of people know about the ‘watch’ command, part of the standard complement of GNU tools available on most Linux distributions, as well as many Linux-like OSes such as VMware ESX and the VMware vMA.
Simply put, it runs a command at a specific interval for you. So if you want to continually see the number of httpd processes running on a host you could use:
watch 'ps -ef | grep httpd | wc -l"
Or maybe you want to watch the temperature on a remote physical host using IPMI. The -n flag changes the number of seconds between the commands:
watch -n 60 -d 'ipmitool -I lan -U username -P password -H host-bmc.address sdr type "Temperature"'
The -d or —differences flag seen above will make it highlight changes. There’s also —differences=cumulative, which makes the differences highlighting sticky, and options to turn off the title & header:
watch -n 1 --d=cumulative -t 'sudo ls -la /var/run'
It’s a simple command, but very useful, and as is usually the case a ‘man watch’ on your host will likely have the rundown on all the parameters, as well as more examples.
A simple one I often use is:
watch -n 1 ‘esxcfg-nics -l’
when building new servers, to figure out which vmnic number corresponds to which physical NIC. I just run that at the console and start plugging in cables. You can see the vmnics go up and down.