脚本功能:检测8080和8081端口是否在运行,如果没在运行,则/opt/tomcat-background/bin/startup.sh
vi /root/aa.sh
#!/bin/bash
i1=`nmap -sS 127.0.0.1 -p 8080 | grep 8080 | awk '{printf2}'`
i2=`nmap -sS 127.0.0.1 -p 8081 | grep 8081 | awk '{printf2}'`
if [ "$i1" == "closed" ]; then
/opt/tomcat-background/bin/startup.sh
fi
if [ "$i2" == "closed" ]; then
/opt/tomcat-zjq-front/bin/startup.sh
fi
每五分钟检测一次
crontab -e
*/5 * * * * sh /root/aa.sh
本文转自flayber 51CTO博客,原文链接:http://blog.51cto.com/406647516/1922499,如需转载请自行联系原作者