脚本功能:检测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 ‘{printf $2}‘`
i2=`nmap -sS 127.0.0.1 -p 8081 | grep $8081 | awk ‘{printf $2}‘`
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
时间: 2024-10-14 03:00:56