参见: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 10 -m 20 $tomcaturl -w %{http_code}) if [ $http_code -eq 200 ]; 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