从网上抄了一份ping关机代码,但是家里网络不稳定脚本里检测两次不通便会关机,现在想增加ping检测次数却不知如何下手。求助各位mjj大佬
- #!/bin/sh
-
- while
-
- ping -c 1 192.168.5.2 > /dev/null
-
- [ $? -eq 0 ];
-
- do
-
- echo
-
- sleep 300
-
- done
-
- echo ‘ AC Power maybe off, checking again after 1 minutes ! ‘ >> /volume1/ups.log;date >> /volume1/ups.log
-
- sleep 60
-
- ping -c 1 192.168.5.2 > /dev/null
-
- if [ $? -eq 0 ]
-
- then
-
- echo ‘ Checkagain, AC Power OK ! ‘ >> /volume1/ups.log;date >> /volume1/ups.log
-
- /usr/sbin/PowerOff1.sh
-
- else
-
- echo ‘ AC Power is already off, shut down NAS Now! ‘ >> /volume1/ups.log;date >> /volume1/ups.log
-
- shutdown -h now
-
- fi
复制代码
|