Here is my script.
#!/bin/sh
if netstat -tln | grep 8443 && ps -ef | grep tomcat | grep java
then
date
echo "Tomcat Running"
else
date
echo "Tomcat Stopped"
source /root/.bash_profile
date
/app/apache-tomcat-8.0.28/bin/startup.sh >> /root/restarttomcat.log 2>&1
echo "Tomcat Restarted"
mailx -s "Tomcat not running" xxxx@gmail.com < /root/tomcatwordings
fi
"tomcatwordings" is file for the email contents.
Here is the crontab
*/2 * * * * /root/checktomcat.sh >> /root/checktomcat.log 2>&1
"checktomcat.log" is the log for the monitoring script
"checktomcat.sh" is the script file with the above content.
No comments:
Post a Comment