Meditations, Musings and Memorial Stones

AVANIM :: TecHarmony :: Watch on OSX

Watch on OSX

February 16, 2009 | Comments: 1

‘watch’ is a great command-line utility that Linux SysAdmins have come to know and love. It allows you to monitor the output from any command, like ‘top’ does for processes, refreshing every -n seconds (2 seconds by default). For example, if you wanted to watch pages being cached on a rails site, you could:

$ cd <RAILS_ROOT>
$ watch ls -R cache/

which would show you something like:


Every 2.0s: ls -R cache/ Mon Feb 16 14:18:18 2009

cache/:
about.data
about.yml
styles.css.data
styles.css.yml

So, you want to do this on your mac as you develop rails sites?

Well, the only problem is that ‘watch’ does not come with OSX. Now, you could try setting up some funky alias in your bash shell profile (.bash_profile) like:


alias watch=“while true; do clear; date; $#; echo ctl-c to quit; sleep 2; done”

Thing is, this is a little hard to get working right. But never fear, best case scenario, you can actually download and install the real ‘watch’ program from here

Just unzip the file, then:


$ cd
$ make # maybe unecessary
$ sudo make install

and voilá! — you’re ready to go. To test, try ‘watch w’ to see who is logged in, and the current load. Control-C to exit.

Comments

fink now has an install for watch – YA!


orionrush on May 02, 2009 at 12:00 PM

Post a comment


(required, but not displayed)

(optional)


(required)