Automate Apache server restart (bounce) through script


Are you thinking of automating Apache server restart which can be done through a crontab entry?
This is how we can do it :
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 /mine/oracle/prodappl/t11.5.0/bin/ApacheBounce"


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:  /mine/oracle/prodappl/11.5.0/bin/ApacheBounce
The below mentioned are the contents of the Apache restart script (ApacheBounce) :
#################################################################################
#Source the ENV file
. /mine/oracle/prodappl/APPSPROD_mine.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 “sandeshachar@mine.com”
sleep 180
#Stops the Apache services
sh $APPLCSF/scripts/PROD_mine/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 $APPLCSF/scripts/PROD_mine/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 “sandeshachar@mine.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 $MINE_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.
 ----------------------------------------------------------------------------------------------------------------------------
  
$ cat  $MINE_TOP/bin/Apacheup.txt
-----------------------------------------------------------------------------------------------------------------------------

No comments:

ORA-00059: Maximum Number Of DB_FILES Exceeded in 19C database

When I am adding datafile to my 19C database facing the below error. SQL> alter tablespace DATA  add datafile '/u01/data/data15.dbf...