IRCDChk
From FrogspawnWiki
Since I have been having problems with an IRC Daemon crashing, I have a script that runs to restart it if it does crash.
pidfile=~/lib/ircd.pid if [ -e $pidfile ] then ircpid=$(cat $pidfile) if `kill -CHLD $ircpid >/dev/null 2>&1` then #IRCD is running, exit cleanly exit 0 else echo IRCD on PID $ircpid dead. Restarting... cd ~/bin ./ircd fi else echo PID file $pidfile does not exist fi
It takes the content of ~/lib/ircd.pid (the pidfile created by default) and does a test kill on it, if that test is successful then the ircd is running, otherwise the ircd isn't running so it needs to be restarted.
Of course this would be useless if it weren't running automatically, so it needs to go into cron
*/5 * * * * ~/bin/chkircd.sh
That has cron run the script every 5 minutes.
Two ways of getting it in cron would be to use crontab -e to start an interactive editor, or echo the content of the current crontab to a file (crontab -l > crontab.txt) then edit that with a text editor of your choice, then read that file back in to crontab with crontab crontab.txt.