#!/bin/sh # # botchk for Socip # # Version of 14.8.2001, Kajetan@Hinner.com # # original version for eggdrop bot, adapted for perl scripts by Kajetan@Hinner.com # # This is a script suitable for use in a crontab. It checks to make sure # your bot is running. YOU NEED A SEPARATE CRON JOB FOR EACH BOT. If your # bot isn't found, it'll try to start it back up. # # You'll need to edit this script for your perl script. # # To check for your bot every 10 minutes, put the following line in your # crontab: # 0,10,20,30,40,50 * * * * /home/mydir/botchk # And if you don't want to get email from crontab when it checks you bot, # put the following in your crontab: # 0,10,20,30,40,50 * * * * /home/mydir/botchk >/dev/null 2>&1 # # change this to the directory you run your bot from: botdir="/tmp/irc" # change this to the name of your bot's script in that directory: botscript="Socip_B.pl" # path to botscript #botdir="/usr/home/khh/ircstat/" botdir="/home/khh/ircstat/" # file for stdout botstdout="/tmp/"$botscript.out # file for errout boterrout="/tmp/"$botscript".err" ########## you probably don't need to change anything below here ########## # echo $0 >/tmp/null0 if ps ax | grep -v grep | grep perl | grep $botscript 1>/dev/null 2>/dev/null then # echo "$botscript OK" # everything ok :-) exit 0 else # not working... start it new then. :) # and send mail # echo "$botscript is not working; new start and mail..." perl $botdir$botscript 1>>$botstdout 2>>$boterrout & # mailx -s "$botscript restarted" khh@bompf < /tmp/irc/mail.txt echo "$botscript restarted" exit 0 fi