[motd.ca]  watch

watch - watch for events

Watch provides a command-line interface to the kqueue facility in BSD. Currently it allows files and processes to be watched. It has the same limitations as kqueue, however, and can only safely watch files on local UFS filesystems.




watch is available as:


To watch a file for any change:

           watch -f /etc/master.passwd

To watch a file for a write:

           watch -f /var/log/sulog -e write

To continously watch a process for forking:

           watch -ct -p `cat /var/run/sshd.pid` -e fork

To watch a daemon for exit, and log exit to syslog:

           watch -d -S daemon.err -p `cat /var/run/sshd.pid` -e exit

To take action when a process exits:

           watch -q -p `cat /var/run/inetd.pid` -e exit && /usr/sbin/inetd