Automate Apache server restart (bounce) through
script.
In this post we will know how to
automate Apache server restart through shell script.
If you are thinking to automating Apache server
restart which can be done through a crontab entry.
Pls check carefully below steps:-
Here is
Details :
Create
the below entry in crontab (Please modify the timing in the cronjob as per your
Apache restart requirement):
10 8
* * * su -c applmgr "sh /oracle/prodappl/11.5.0/bin/ApacheBounce.sh"
Note: ApacheBounce is the script
to be created which will do the Apache restart. Mineserver is the servername
where Apache services are running.
This
example is for the services running on a single node and same concept can be
followed while implementing on multiple servers.
Location of the bounce script: /oracle/prodappl/11.5.0/bin/ApacheBounce.sh
The below mentioned are the contents of the Apache restart script (ApacheBounce.sh)
:
#################################################################################
#Source
the ENV file
.
/oracle/prodappl/APPSPROD_XXX.env
Sleep 5
# Notify all users before the
restart.
cat $MINE_TOP/bin/ Apachedown.txt | mailx -s "PRODUCTION - Apache Bounce will happen in 3 mins " -c “oracledba@gmail.com”
sleep 180
#Stops
the Apache services
sh $ADMIN_SCRIPTS_HOME/adapcctl.sh stop
sleep 10
# Kill leftover Apache processes
kill_processes=`ps -ef | grep "/iAS/Apache/Apache/bin/" | awk '{print $2}'`
echo
$kill_processes
kill -9
$kill_processes
sleep 5
sh $ADMIN_SCRIPTS_HOME/adapcctl.sh
start # starts the Apache services
sleep 5
# Notify all
users after restart
cat
$CUST_TOP/bin/Apacheup.txt | mailx -s "PRODUCTION Apache Bounce Complete"
-c “oracledba@gmail.com”
#################################################################################
End of
file.
Note: Save the content of the
email to be sent in a text file: Apachedown.txt and Apacheup.txt
For
example:
$ cat $CUST_TOP/bin/Apachedown.txt
----------------------------------------------------------------------------------------------------------------------------
Hi All,
PRODUCTION
Apache services are scheduled to be bounced in 2 minutes.
Please
ignore any alerts while it is being bounced.
Thanks,
Oracle
Apps DBA Team
----------------------------------------------------------------------------------------------------------------------------
$ cat $CUST_TOP/bin/Apacheup.txt
-----------------------------------------------------------------------------------------------------------------------------
Hi All,
PRODUCTION
Apache services have been restarted.
Please
report if there are any issues.
Thanks,
Oracle
Apps DBA Team
No comments:
Post a Comment
Thanks for reading till end. I hope this will help you more to improve your knowledge.
Now it's your turn!
What do you think? Share your experience in the comments box and subscribe for more interesting post.