#!/bin/ksh
# monitor.sh
# description:  monitor a process id with locking PID file. This script is added in the crontab entry
#                      file and ran according to your needs ( e.g., every 5, 15 or 1/2 hour intervals)
#
# 12-09-99    date create
#  author          robin manapsal

PID=`ps -ef | grep netscape | grep -v grep | awk '{print $2}' `
NETSCAPE=/opt/netscape/netscape
LOCKFILE=/.netscape/lock
CONTACT="youremaill address here"

if [ ! -a $PID ];then
  echo "Netscape Server is running with Process ID $PID"
else
  echo "Netscape Server  is down and will be restarted shortly"
  mailx -s "Netscape Server is down and will be restarted shortly"  $CONTACT < /dev/null > /dev/null 2>&1
  rm -f $LOCKFILE
  exec $NETSCAPE &
  echo "Netscape has been restarted"
fi