shell脚本检查Tomcat运行状态
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin export 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.sh Weburl=http://localhost:8080 TomcatMonitorlog=/var/log/TomcatMonitor.log Monitor(){ 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 $StartTomcat fi fi } Monitor >> $TomcatMonitorlog
*/5 * * * * /etc/swd/check_tomcat.sh > /dev/null 2>&1
本文出自 “梁恩宇-9527” 博客,请务必保留此出处http://liangey.blog.51cto.com/9097868/1660283
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。