利用wget檢測網頁是否正常訪問


#!/bin/bash

function CheckUrl() {
timeout=5
fails=0
success=0
while true
    do
        wget --timeout=5 --tries=1 https://www.google.com -q -O /dev/null
        #use wget to CheckUrl can be used 
        if [ $? -ne 0 ]
            then
                let fails=fails+1
        else
                let success=success+1
        fi
        if [ $success -gt 1 ];then
            echo "Success"
            exit 0
        fi
        if [ $fails -gt 0 ];then
            echo "Failed"
            exit 1
        fi
    done
}
CheckUrl


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM