while循环判断服务端口是否正常启动

    技术2025-05-22  46

    #!/bin/bash PORT=3306 sum=0 . /etc/init.d/functions echo -n "Starting..." while [ $sum -le 60 ] do netstat -tunap | grep -w $PORT # [ $? -eq 0 ] && echo "Start ok !!!" && break [ $? -eq 0 ] && action "Start OK !!!" /bin/true && break sleep 1 echo -n "." # [ $sum -eq 20 ] && echo -e "\nStart failed !!!" [ $sum -eq 60 ] && echo "" && action "Start failed !!!" /bin/false let sum++ done
    Processed: 0.011, SQL: 9