Openwrt 网络状态监测&&自动修复Shell脚本

date_tmp=`date`
str_tmp="..........Loop start."
echo "$date_tmp $str_tmp" >>/net.log
sleep 300

while true
do
    sleep 120
    
    result=`ping www.baidu.com -c 10 | grep "min/avg/max" -c`

    if [ "$result" != "1" ]; then
      date_tmp=`date`
      str_tmp="..........The host is unreachable."
      echo "$date_tmp $str_tmp" >>/net.log
      /etc/init.d/network restart
    else
      date_tmp=`date`
      str_tmp="..........Everything is ok ."
      echo "$date_tmp $str_tmp" >>/net.log
    fi
done

 
android-b81988249437ed80

分享到:更多 ()