Launch script for cron

From: The Merciless Lord of Everything (serces@mud.dk)
Date: 01/19/00


Hiya

I got tired of always having to login to run up the mud whenever the
machine was rebooted (has happend quite frequently lately sadly :) So I
sat down and wrote this script to be put in cron, that way even if the
autorun script should determine to crash (god should know why though),
it'd get started 15 minutes later.

Somewhere in the top of autorun put in these lines, I put it before the
PORT=????? assigment, but anywhere before 'while ( : ) do' should actually
work..

PIDFILE=".pid"
SCRIPT="autorun"
if [ -f $PID ]; then
# Check if autorun is running, if so, do nothing!
   PID=`cat $PIDFILE`
   kill -0 $PID 2>&1 && echo autorun already running, exitting && exit
fi
echo $$ > $PIDFILE
....(Autorun continues as normally)

this is meant as a security for autorun, so it won't start up twice.

after that I made this launcher (I called it launch.sh):
---- START launch.sh ----
#!/bin/sh
# 0,30 * * * * $HOME/launch.sh

# Path to the program
path="$HOME"

# The Program Name
prog="$path/autorun"

# The PIDfile
pidfile="$path/.pid"

if [ -f $pidfile ]; then
 pid=`cat $pidfile`
 kill -0 $pid 2>&1 || (cd $path;rm -f $pidfile;./$prog 2>&1 &)
else
  (cd $path;./$prog 2>&1 &)
fi
----- END launch.sh ----

And dumped this into my crontab with
0,30 * * * * $HOME/launch.sh

Whoop, I now get it up at latest 30 minutes after a reboot of the
machine. I thas been tested on a FreeBSD and on a Linux system (I dunno if
it is compatible with other *Nices, though I see no reason why not).

If you chose to use this, be aware that I use my standard disclaimer "You
use it, Your fault if something breaks!" :) though I can't see why
anything should happen.. :)

Greetings

S. P. Skou



"The Law of Self Sacrifice"
When you starve with a tiger, the tiger starves last.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT