Linux style 'watch' command on Mac OS X

There is a handy command on Linux, and some more recent Unix machines called 'watch'. Any command you might like to run repetitively to keep an eye on something can run be run over and over with the output displayed on a cleared terminal. You might use it to keep an eye on your disk usage while doing something disk intensive like this:

watch df -h

I've also found it particularly handy to test out cron job scripts.

However normally on Mac OS X the command is not available. You can write a one line bash script to do a similar job.

while clear; date; df -h; do sleep 2; done

This is great for one off occasional use, and if you can remember it! If you really would like to use watch though, there is a way. Doing a quick search on the Internet I found the following article, which has a 'watch' command replacement. It works just the same as the one on Linux, so I would not be surprised if it is a direct port. You can find it at the following address.

http://osxdaily.com/2010/08/22/install-watch-command-on-os-x

Even easier if you have Homebrew installed:

brew install watch

Or if you have MacPorts

sudo port install watch
Back to Top