This script is for to restart the tomcat server by listening the port...In case the port closed the script automatically call the script and trigger mail to administrator..
---------------------------------------------------------------------------------------------------
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
#Tomcat 8080
#The command to exit your program or service
progStart=exit
#Writes an entry to the log file indicating when the script last ran
echo "`date` Checking tomcat " > log_jasper.txt
#Check if program is running by using the ps command
#the -z option returns True if the length of its operand "STRING" is zero.
if [[ -z ` netstat -tulpn | grep 8080` ]]; then
#Optional - Send a mail that program is being restarted
sh /usr/local/apache-tomcat/bin/startup.sh
echo "`date` Jasperserver 8080 not detected" | mail -s "Jasperserver shuntdown Notification" nataraj.r@gmail.com
$progStart
else
echo "Tomcat 8080 is running `date`"
fi
No comments:
Post a Comment