Restart Platform

#!/bin/bash
#Restart Platform WL Process Daily
#modified Andrew , 04/01/2011 to only send mail in case of failure

#Set Up Script Variables

HOST=`hostname`
DATE=`date`
LOG=/tmp/`hostname`-wlrestart.log
MAIL=xx-noc@zzz.com
SCRIPT1=/weblogic/prod/bin/weblogic.platform.managed
SCRIPT1OPT=restart
WLLOGDIR=/weblogic/prod/logs/
WLPLATLOG=platform-prod.log
SLEEPWAIT=180
READLINES=400


#Run external restart script
echo "Running ${SCRIPT1} ${SCRIPT1OPT}" >> ${LOG}
${SCRIPT1} ${SCRIPT1OPT} > ${LOG}

#Wait for server to shut down
sleep ${SLEEPWAIT}

tail -${READLINES} ${WLLOGDIR}${WLPLATLOG} | grep -i "Server started in RUNNING mode" >> ${LOG}
RESULT=$?


if [ ${RESULT} != 0 ]
        then
        #This gets run if the logs don't show the magic phrase "Server started in RUNNING mode"
        echo " " >> ${LOG}
        echo "Server ${HOST} does not appear to have started correctly" >> ${LOG}
        echo " "  >> ${LOG}
        echo "From /home/weblogic/ops/restart_platform.sh on ${HOST}" >> $LOG
        echo " " >> ${LOG}

        #Mail Out
        echo "Sending notification mail.." >> ${LOG}
        mail ${MAIL} -s "${HOST} - Weblogic Managed Restart @ ${DATE}" < ${LOG}

        exit 1


else
        # $RESULT is 0, so this gets run if the server has started normally.
        #In this case, an email should not be sent, hence commented out lines for mail sending
        echo " " >> ${LOG}
        echo "Server started in RUNNING mode" >> ${LOG}
        echo " " >> ${LOG}
        echo "From /home/weblogic/ops/restart_platform.sh on ${HOST}" >> $LOG
        echo " " >> ${LOG}

        #Mail Out
        echo "Sending notification mail.." >> ${LOG}
        #mail ${MAIL} -s "${HOST} - Weblogic Managed Restart @ ${DATE}" < ${LOG}
fi

#Done
exit 0

rb/restartplatform.txt · Last modified: 18/07/2019 15:54 by andrew