天天看點

檢測端口并進行下一步

腳本功能:檢測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

每五分鐘檢測一次

crontab -e

*/5 * * * * sh /root/aa.sh

      本文轉自flayber  51CTO部落格,原文連結:http://blog.51cto.com/406647516/1922499,如需轉載請自行聯系原作者