本文共 811 字,大约阅读时间需要 2 分钟。
shell判断执行
check.sh
d1=`date +%Y%m%d"-"%H%M%S".txt"`w1=`curl -s --connect-timeout 5 -m 10 http://xxx.xxx.xxx.xxx:7017/index.html|grep submit|wc -l`w2=`netstat -tunlp|grep LISTEN|grep 7017|wc -l`if [ $w1 == 0 ] && [ $w2 -gt 2 ]; then echo "killed - "`date` >> /root/check.txt ps -ef|grep 8192m|grep -v grep|awk '{print $2}'|xargs jstack > $d1 ps -ef|grep 8192m|grep -v grep|awk '{print $2}'|xargs kill -9 nohup /start.sh > /start.log & echo "started - "`date` >> /root/check.txtelse echo "ok"fisleep 5w3=`ps -ef|grep 8192m|grep -v grep|wc -l`if [ $w3 == 0 ]; then echo "restart - "`date` >> /root/check.txt nohup /start.sh > /start.log & echo "restarted - "`date` >> /root/check.txtelse echo "ok3"fi
每分钟检查执行:
# crontab -l
* * * * * /root/check.sh > /dev/null 2>&1相关:
转载地址:http://qnsof.baihongyu.com/