由于tomcat服务经常会出现进程在,但是服务却无法正常响应的问题,而且进程跑在docker容器中,使用zabbix控制不是很方便,故此写了个简单的小脚本:
#!/bin/bash
#Author:fansik
while true
do
code=`curl --connect-timeout 5 -m 10 -I -s -w "%{http_code}" -o /dev/null http://localhost:8080/favicon.ico`
datetime=`date +"%F-%T"`
if [ $code != 200 ]
then
sh /usr/local/tomcat/rbtomcat.sh &> /dev/null
echo "At $datetime The service is restart!!!" >> restart.txt
fi
sleep 10
done