Crontab Setup
1.
Notes before you begin:
o
Newer versions of Eggdrop include a script called "autobotchk"
which automates setting up your crontab. It's located in the bot's scripts/
subdirectory, and is recommended if available. If not available, then the rest
of this guide demonstrates how to set up crontab manually.
o
Text in RED must be editted to fit
your situation.
o
Text in BOLD means its a command to be entered into the
shell.
o
On UNIX/Linux systems, all filenames and commands are CASE
SENSITIVE.
- First, you must set up a botchk script for each bot
you run on your shell, which is located in each bots' scripts/ dir.
So, change to your bot's directory and with your favorite editor, open up
this file:
pico scripts/botchk
- Next, edit the five variables located in the script.
See the example for a bot with the name "LamestBot" below:
#! /bin/sh
#
# botchk
#
# $Id: botchk,v 1.6 2002/02/27 18:21:46 guppy Exp $
#
# 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 bot.
#
# To check for your bot every 10 minutes, put the following line in your
# crontab:
# 0,10,20,30,40,50 * * * * /home/mydir/mybot/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/mybot/botchk >/dev/null 2>&1
#
# change this to the directory you run your bot from (capitalization COUNTS):
botdir="/home/user/botdir"
# change this to the name of your bot's config file (capitalization COUNTS):
botscript="bot.conf"
# change this to the botnet-nick of your bot (capitalization COUNTS):
botname="bot"
# change this to the name of your bot's userfile (capitalization COUNTS):
userfile=" bot.user"
# change this to the name of your bot's pidfile (capitalization COUNTS):
pidfile="pid.bot "
########## you probably don't need to change anything below here ##########
cd $botdir
# is there a pid file?
if test -r $pidfile
then
# there is a pid file -- is it current?
botpid=`cat $pidfile`
if `kill -CHLD $botpid >/dev/null 2>&1`
then
# it's still going -- back out quietly
exit 0
fi
echo ""
echo "Stale $pidfile file, erasing..."
rm -f $pidfile
fi
if test -r CANTSTART.$botname
then
if test -r $userfile || test -r $userfile~new || test -r $userfile~bak
then
echo ""
echo "Userfile found, removing check file 'CANTSTART.$botname'..."
rm -f CANTSTART.$botname
fi
fi
# test if we have run botchk previously and didn't find a userfile
if test ! -f CANTSTART.$botname
then
echo ""
echo "Couldn't find bot '$botname' running, reloading..."
echo ""
# check for userfile and reload bot if found
if test -r $userfile
then
# It's there, load the bot
./$botscript
exit 0
else
if test -r $userfile~new
then
# Bot f*@!ed up while saving the userfile last time. Move it over.
echo "Userfile missing. Using last saved userfile..."
mv -f $userfile~new $userfile
./$botscript
exit 0
else
if test -r $userfile~bak
then
# Userfile is missing, use backup userfile.
echo "Userfile missing. Using backup userfile..."
cp -f $userfile~bak $userfile
./$botscript
exit 0
else
# Well, nothing to work with...
echo "No userfile. Could not reload the bot..."
echo "no userfile" > CANTSTART.$botname
exit 1
fi
fi
fi
fi
exit 0
- Next, we want to set the script executable, if it
isn't already.
chmod 700 scripts/botchk
- Now we want to go back and double check your eggdrop's
config file. Many people do not correctly set up the very first line, which
is supposed to look like:
#!/HOMEDIR/EGGDROPDIR/eggdrop
This is the exact path (capitalization
counts) to the eggdrop binary in your bot's directory (not the
directory itself, and not the config file). Make sure to change HOMEDIR
and EGGDROPDIR to match your situation, and make sure the #! is at the beginning
(it has special meaning).
- At this point, it might be wise to test if you have
everything set up correctly so far. Kill the bot, and run the botchk script.
ps -x
kill -9 PID
scripts/botchk
PID is a "Process IDentification" number for each
program current running. If your botchk file is set up correctly, it will launch
your bot.
- Next step is to set up the crontab. Open your favorite
editor with a new empy file called "mycron" in your home dir.
pico ~/mycron
- For each bot you run on your shell, add one of these
lines:
0,10,20,30,40,50 * * * * /home/user/bot/scripts/botchk
>/dev/null 2>&1
0,10,20,30,40,50 * * * * /home/user/altbot/scripts/botchk
>/dev/null 2>&1
Each will have its own botchk file.
- Save and exit the editor, and set crontab to use the
file you just made.
crontab ~/mycron
- Lastly, kill your bot(s) again and wait ten minutes to
check if they restart. If not, go back through all these steps and double
check everything. If it still doesn't work, you my not have access to
crontab on your shell, so check with your admin.
- In addition, the crontab program usually offers these
useful tools:
crontab -e
Interactively edits your current
crontab entries.
crontab -l
Lists all your current crontab
entries.
crontab -r
Removes all your current crontab
entries.
*Note* Although I don't remember where I obtained this, it
is excellent and I well writen! Many thanks to the writer!!