路由器如何写一个脚本,让路由器每时每刻ping 百度,ping不通三次就自动重启
四川省网友说:#!/bin/bash counter=0 while true; do if ping -c 1 www.baidu.com &> /dev/null; then counter=0 else ((counter++)) fi if [[ $counter -ge 3 ]]; then reboot fi sleep 1 done 复制代码
云南省网友说:watchdog 请
山西省网友说:chatgpt
河北省网友说:Op有这个功能。
青海省网友说:写个shell丢上去就行了
安徽省网友说:tries=0
while [[ $tries -lt 3 ]]
do
if /bin/ping -c 1 baidu.com >/dev/null
then
echo “online, exit” >> /root/log.txt
exit 0
fi
tries=$((tries+1))
sleep 1
done
echo “offline, reboot” >> /root/log.txt
/sbin/reboot
把上面的脚本定时执行就行
湖南省网友说:这是啥奇怪需求
黑龙江省网友说: