I was trying to do this for a little while so in case anyone's interested,
here it is. Most of the code was kindly sent to me by other people so do not
blame me for the mistakes. This script(auto) checks ZOPE every 15'th minute
and if it does not run, it will restart it. It has been working without a
problem on FreeBSD 4.0 after I patched ZOPE's pidfile for LF's. (without
that little operation it returns an error message and restarts ZOPE every
time without checking it)

I am running this from crontab:

SHELL=/bin/sh
0,15,30,45 * * * * /home/user/auto

And this script(auto) is sitting in my user directory:

#!/bin/sh

ZOPEDIR="/home/user/zope"
INFOMAIL="[EMAIL PROTECTED]"

STARTFILE="$ZOPEDIR/start"
STOPFILE="$ZOPEDIR/stop"
PIDFILE="$ZOPEDIR/var/Z2.pid"
PID1ACTIVE=0
PID2ACTIVE=0
if [ -x $STARTFILE ]; then
  if [ -r $PIDFILE ]; then
    PID1=`cut -d" " -f1 $PIDFILE`
    PID2=`cut -d" " -f2 $PIDFILE`
    if
    kill -0 $PID1 2>/dev/null
    then
      PID1ACTIVE=1
    fi
    if
    kill -0 $PID2 2>/dev/null
    then
      PID2ACTIVE=1
    fi
  fi
  if [ $PID1ACTIVE -eq 0 -o $PID2ACTIVE -eq 0 ]; then
    $STOPFILE >/dev/null 2>&1
    sleep 10
    $STARTFILE
    date | mail -s"Zope restarted" $INFOMAIL >/dev/null 2>&1
  fi
fi

Regards,

George



_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to