首页 > 技术知识 > 正文

通过shell脚本编写:

#!/bin/sh tries=0 ok=0 echo — my watchdog start — while [ “1” = “1” ] do if /bin/ping -c 1 114.114.114.114 >/dev/null then echo “net is fine!” >/dev/null else echo “net is offline!” tries=$((tries+1)) if [ $tries -gt 20 ] ; then tries=0 /app/reconnect.sh & killall -9 quectel-CM else echo $tries fi fi sleep 3 done

定时去ping 114,获取网络状态,网络断开达到设定期限,需要重启网络。

猜你喜欢