当前位置:   article > 正文

openwrt启用定时器检测断网重连_openwrt检测网络在线

openwrt检测网络在线

脚本放到root底下:vi my_watchdog.sh

写完添加.sh可执行权限

chmod 777 my_watchdog.sh

  1. #!/bin/sh
  2. #sleep 100
  3. DATE=`date +%Y-%m-%d-%H:%M:%S`
  4. tries=0
  5. echo --- my_watchdog start ---
  6. while [[ $tries -lt 5 ]]
  7. do
  8. if /bin/ping -c 1 8.8.8.8 >/dev/null
  9. then
  10. echo --- exit ---
  11. # echo $DATE OK >>my_watchdog.log
  12. exit 0
  13. fi
  14. tries=$((tries+1))
  15. sleep 10
  16. # echo $DATE tries: $tries >>my_watchdog.log
  17. done
  18. echo $DATE network restart >>my_watchdog.log
  19. /etc/init.d/network restart
  20. #echo $DATE reboot >>my_watchdog.log
  21. #reboot1

定时器放/etc/crontabs/root/

  1. */1 * * * * /root/my_watchdog.sh
  2. 0 0,4,8,12,16,20 * * * date -u +"%Y.%m.%d-%H:%M:%S" >/usr/data/time_backup
  3. 0,1,11,21,31,41,51 * * * * /usr/bin/set_kernel_timezone >/dev/null 2>&1
  4. 0 0,4,8,12,16,20 * * * /tmp/bw_backuo/do_bw_backup.sh
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/170672
推荐阅读
相关标签
  

闽ICP备14008679号