vps交流

求助mjj,修改linux ping 关机脚本


从网上抄了一份ping关机代码,但是家里网络不稳定脚本里检测两次不通便会关机,现在想增加ping检测次数却不知如何下手。求助各位mjj大佬求助mjj,修改linux ping 关机脚本

  1. #!/bin/sh
  2. while
  3. ping -c 1 192.168.5.2 > /dev/null
  4. [ $? -eq 0 ];
  5. do
  6. echo
  7. sleep 300
  8. done
  9. echo ‘ AC Power maybe off, checking again after 1 minutes ! ‘ >> /volume1/ups.log;date >> /volume1/ups.log
  10. sleep 60
  11. ping -c 1 192.168.5.2 > /dev/null
  12. if [ $? -eq 0 ]
  13. then
  14. echo ‘ Checkagain, AC Power OK ! ‘ >> /volume1/ups.log;date >> /volume1/ups.log
  15. /usr/sbin/PowerOff1.sh
  16. else
  17. echo ‘ AC Power is already off, shut down NAS Now! ‘ >> /volume1/ups.log;date >> /volume1/ups.log
  18. shutdown -h now
  19. fi

复制代码

ping -c 1 其他不用我多说了

雁过拔毛的MJJ 发表于 2022-6-11 11:01
ping -c 1 其他不用我多说了

不愧是大佬求助mjj,修改linux ping 关机脚本