tomcat运行监控脚本,自动启动

参见:http://www.cnblogs.com/coffee_cn/p/8279165.html

monitor.sh

#!/bin/sh
monitorlog=/usr/local/tomcat/logs/monitor.log monitor()
{
tomcatcache=/usr/local/tomcat/work
tomcaturl=https://www.xxxxxx.com/ echo "[info]$(date +'%F %H:%M:%S')"
http_code=$(curl -s -o /dev/null --connect-timeout -m $tomcaturl -w %{http_code})
if [ $http_code -eq ]; then
echo "[info]tomcat ok"
else
echo "[error]tomcat died ($http_code)"
rm -rf $tomcatcache
service tomcat stop
service tomcat start
fi
} monitor>>$monitorlog

crontab

*/5     *       *       *       *       /usr/local/tomcat/bin/monitor.sh

hosts

127.0.0.1 www.xxxxxx.com

上一篇:canvas 画圈 demo


下一篇:AI - TensorFlow - 第一个神经网络(First Neural Network)