Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Sep 2000 22:18:24 +1000
From:      "George Osvald" <mail@okstudio.com.au>
To:        <freebsd-questions@FreeBSD.ORG>
Subject:   running a linux script on FreeBSD
Message-ID:  <000001c02621$892d5680$28f438cb@gosvald>

index | next in thread | raw e-mail

[-- Attachment #1 --]
I have a script that is to be executed from crontab to check whether
application is running and if it isn't it should restart it. It works fine
on my RED HAT 6.2 box but I can't get it working on FreeBSD 4.0-RELEASE.
On Linux it doesn't do anything if the application is running. It simply
checks the status and only restarts when the application stops working.
On FreeBSD it stops and then restarts the bloody thing every time. I wander
if anyone knows what should be changed for this script to run on FreeBSD.
Any help would be appreciated.

--------------------------------------------

#! /bin/sh

ZOPEDIR="/home/virtuals/user/zope"
INFOMAIL="mail@okstudio.com.au"

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
    ps -p $PID1 >/dev/null 2>&1
    then
      PID1ACTIVE=1
    fi
    if
    ps -p $PID2 >/dev/null 2>&1
    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


[-- Attachment #2 --]
#! /bin/sh

ZOPEDIR="/home/virtuals/gosvald/zope"
INFOMAIL="mail@okstudio.com.au"

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
    ps -p $PID1 >/dev/null 2>&1 
    then
      PID1ACTIVE=1
    fi
    if
    ps -p $PID2 >/dev/null 2>&1
    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
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001c02621$892d5680$28f438cb>