In this document, we will set a crontab to restart our managed server.
We will follow below steps :
1. Create a python script to stop the server.
2. Now create python script to start server.
3. Now create a shell script to run these python scripts.
4. Now create a script to run in crontab.
5. Now schedule the crontab as required.
1. Create a python script to stop the server as,
$mkdir -p /u01/oracle/scripts
$vim stopappsrvr.py
connect('weblogic','','t3://<WebLogic Admin Server IP>:<AdminPort')
exitonerror=false
print "** Starting App Server **"
shutdown('AppServer', 'Server', force="true")
exit()
:wq
2. Now create python script to start server as,
$vim startappsrvr.py
connect('weblogic','','t3://<WebLogic Admin Server IP>:<AdminPort')
print "** Starting App Server **"
start(name="AppServer", block="true")
exit()
3. Now create a shell script to run these python scripts as,
$vim rst.sh
#App server is going to stop
echo `date`
export FMW_HOME=/u01/app/oracle/Middleware/Oracle_Home
$FMW_HOME/oracle_common/common/bin/./wlst.sh /u01/app/oracle/scripts/stopappsrvr.py
echo `date`
sleep 300
echo `date`
$FMW_HOME/oracle_common/common/bin/./wlst.sh /u01/app/oracle/scripts/startappsrvr.py
echo `date`
:wq
4. Now create a script to run in crontab as,
$vim restartsrvr.sh
. /u01/app/rst.sh > restart_$(date +"%Y_%m_%d_%I_%M_%p").log
:wq
5. Now schedule the crontab as required,
$crontab -e
#to run at midnight daily
0 0 * * * /u01/app/./restartserver.sh
#to run at 1 PM daily
0 14 * * * /u01/app/./restartserver.sh
No comments:
Post a Comment