Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cd /usr/local/bin/
- #!/bin/sh
- checkNet_01=`ping -c 2 168.95.1.1 | grep 0% | awk '{print $6}'`
- checkNet_02=`ping -c 2 61.31.1.1 | grep 0% | awk '{print $6}'`
- # echo 訊息為 debug 用,取消註解即可顯示
- echo $checkNet_01
- echo $checkNet_02
- # 檢查變數是否「not」0%,若條件成立,則代表網路不正常
- # 若網路不正常,則呼叫「其它處理腳本或指令」
- # 為避免誤判,只有在兩家 ISP DNS 都 ping 不到的情況下,條件才成立
- 跑sh沒有出現0%
- 出現
- received,
- received,
- 後來我用
- #!/bin/bash
- sites='http://www.google.com/ http://tw.yahoo.com/'
- for site in $sites ; do
- wget -t 2 -T 120 $site -O- >/dev/null 2>&1
- if [ $? != 0 ] ; then
- reboot
- else
- echo "Connection OK"
- fi
- done
- 就成功了
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement