For several months, we were dealing with a problem where the iPlanet scheduler was dying, which meant that the daily webserver restart wasn't happening, or else the scheduler was dying after stopping the port but of course wasn't around to start it back up. So I wrote this script to guarantee that the schedule would always be running; and would restart it if needed.
The script is put into cron and run at 5 minute intervals. It has extremely little overhead, although I wrote it out to use a working file instead of writing to variables. I meant to go back and revise it, but it worked so well that there was never any real need to do so.
#!/bin/ksh#######################################################
# Script to find out when the iPlanet Scheduler process is dying,
# and also to automatically restart it and notify us when this
# happens.
# 11/28/06
# Script file name: sch-check.ksh
#################################################################
WORK_DIR=/usr/usd/scripts/teas-sched/
DATE_TM=`date +%H%M-%m-%d-%Y`
DATE_HM=`date +%H%M`
DATE_M=`date +%m%d%Y`
DATE_DMY=`date +%m-%d-%Y`
DATE_FULL=`date -u`
SYS_NAME=`uname -n`
# Find out if the scheduler is running:
ps -ef grep schedulerd grep -v grep > ${WORK_DIR}/result
awk '/iplanet6/{print $2}' ${WORK_DIR}/result > ${WORK_DIR}/pid-sched
# If...then...fi statement should start the scheduler if the pid-sched is empty
PID=`cat ${WORK_DIR}/pid-sched`
if [[ ${PID} -eq 0 ]] ;
then /sbin/init.d/ns-schedulerd start
mailx -s "iPlanet Scheduler on ${SYS_NAME} was restarted at ${DATE_HM} on ${DATE_DMY}" $(<${WORK_DIR}/maillist) < /${WORK_DIR}/result
echo "iPlanet Scheduler on ${SYS_NAME} was restarted at ${DATE_HM} on ${DATE_DMY}" >> /var/adm/sch-check.log
else
echo "Scheduler is running ${DATE_DMY}" >> ${WORK_DIR}/result
fi
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment