path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/binexport Java_home=/usr/java export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar export path= $PATH: $JAVA _home/bin:/usr/local/pcre/bin:/usr/local/ffmpeg/bin tomcatid= ' ps - ef|grep tomcat-5.5|grep -v ' grep ' |head -1|awk ' {print $2} ' StartTomcat=/usr/ local/tool/tomcat-5.5/bin/startup.shweburl=http://localhost:8080tomcatmonitorlog=/var/log/ Tomcatmonitor.logmonitor () {echo "START CHECK TOMCAT .." if [ $TomcatID ];then echo "the tomcatid is $TomcatID" tomcatservercode= ' curl -i $Weburl > /etc/swd/status.txt ' Status= ' cat /etc/swd/status.txt|head -1|awk ' {print $2} ' if [ $Status -eq 200 ];then echo "Tomcat is ok" else echo "Tomcat is error" kill -9 $TomcatID sleep 3 $ starttomcatfi fi}monitor >> $TomcatMonitorlog
*/5 * * * */etc/swd/check_tomcat.sh >/dev/null 2>&1
This article is from the "Liang Enyu-9527" blog, be sure to keep this source http://liangey.blog.51cto.com/9097868/1660283
Shell script checks Tomcat run state