Check if your raspberry pi linux is connected to internet
This simple script just checks if your Raspberry Pi is connected to the Internet or not. So using this script is really easy, it will make Raspberry Pi reboot itself if it’s not connected to the Internet or do something else to get it connected again. This has saved me so many times when I have been using my headless Raspberry Pi setup and when my Raspberry Pi has been connected to Internet via 3G/4G USB modem and it has lost the connection once again.
#!/bin/bash ping -c 3 126.96.36.199 > /dev/null 2>&1 let a=$? if [ "$a" = "0" ]; then echo "We have connection." else echo "We have lost connection." fi