Labels

Thursday, September 6, 2012

weblogic server restart Script using crontab in unix without any manual intervention

#! /bin/ksh
#This script is used for restarting the Weblogic server using CRONTAB
#-------------------------------------------------------------------
# Mail list is used to email the list of users once the restart is done
Maillist=" "
# Mail file is the file which will get emailed to the mail list users
Mailfile= " "
#This is the temporary log file where stopWeblogic.sh result will be stored
> Stop_log
# Stopping the Server
echo "Stopping Weblogic server"
. ./stopWebLogic.sh > Stop_log 2>& 1
sleep 90
echo "Confirming that the Weblogic server stopped"
. ./stopWebLogic.sh >> Stop_log 2>& 1
# Searching for the exception when you shut down the weblogic server for the second time
egrep '[Destination unreachable | "OPUSServer" was shutdown successfully]' Stop_log > /dev/null
if [ $? -eq 0 ]
then
echo "Weblogic server stopped successfully"
# Starting the Server
echo "Trying to start Weblogic server"
#. ./startWebLogic.sh > Start_log 2>& 1 &
. ./startWebLogic.sh > /dev/null
#Getting the process id for startWebLogic.sh process
id=$!
i=0
until [ $i -gt 1 ]
do
sleep 90
grep "Server started in RUNNING mode" /prod/opus/OPUS_CONS1/logs/wl-domain.log > /dev/null
if [ $? -eq 0 ]
then
echo "Weblogic server started successfully"
#Killing the process startWebLogic.sh using process id
#kill -9 $id
#echo "Killed startweb"
break
fi
i=`expr $i + 1`
done
if [ $i -ne 2 ]
then
echo "Weblogic server restarted successfully"
mailx -s "Weblogic_server name Restarted Succesfully" -r $Maillist < $Mailfile

else
echo "Weblogic server failed to start"
mailx -s "Weblogic_server name failed to start" -r $Maillist
fi
else
echo "Failed to stop Weblogic server"
mailx -s "Failed to stop Weblogic server" -r $Maillist
fi
echo "Completed the script"
exit

No comments:

Post a Comment