A fantastic article on swatch (http://www.linux-mag.com/id/7807) included this delightfully simple framework for rolling your own daemons. If you take a moment to read it, you'll see a lot of unix design principles relating in perfect harmony:
#!/bin/sh
# Simple Log Watcher Program
case "$1" in 'start')
/usr/bin/swatch --daemon --config-file=/etc/swatch.conf --tail-file=/var/log/auth.log --pid-file=/var/run/swatch.pid
;;
'stop') PID=`cat /var/run/swatch.pid` kill $PID
;;
*) echo "Usage: $0 { start | stop }
;;
esac
exit 0
No comments:
Post a Comment