Script to restart the weblogic server using crontab in unix without any manual intervention
Problem Description This script can be used to restart the weblogic server using crontab in unix without any manual intervention.
|
Solution Description This script can be used to restart the weblogic server without any manual intervention. It also sends email to the list of people once the restart is done.We can add few more manipulations if you need before restarting the weblogic server. This can be enabled through crontab in the unix. |
|
#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
else
echo "Weblogic server failed to start"
mailx -s "Weblogic_server name failed to start" -r
fi
else
echo "Failed to stop Weblogic server"
mailx -s "Failed to stop Weblogic server" -r
fi
echo "Completed the script"
exit
Venkat,
This script looks nice.
I suggest you that, it is better you use any sytaxHighlighter it gives much clearity for the script.
Why did you stopped 2 times the server?
Keep updating good stuff...
Cheers
;.
I don't know use of crontab in unix for weblogic thank for introducing new script.It gives me inspiration to try more in my weblogic training looking in your posts.
The answer for question How does a server know when another server is unavailable? i am looking here i found easy.
Weblogic Administration Training
Nice Information... Really useful this..
Weblogic Admin Training