Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3552

Troubleshooting • Re: Auto-reboot if ping to gateway fails

$
0
0
You ran the wrong script, a simple mistake ;)

The first one I posted was to restart the wifi which is what you ran..

You should have run the second one I posted which is this one, which has the reboot command in it.

Code:

#!/bin/bash# keep wifi aliveecho "................................................"date "+%Y.%m.%d %H:%M:%S"echo " "ping -c2 192.168.1.1 # replace this IP with replace with IP you want to test too if [ $? != 0 ] then   echo " "  echo "No network connection, Rebooting Pi"    sleep 30  sudo reboot  else    echo " "    cat /proc/net/wirelessfiecho "................................................"echo " "
save this as checkwifi.sh and make it executable as you did with the first one and see if that will reboot your pi.

Statistics: Posted by pcmanbob — Sun Feb 11, 2024 11:51 am



Viewing all articles
Browse latest Browse all 3552

Trending Articles