Skip to content

Instantly share code, notes, and snippets.

@summer20100514
Forked from ankel/check_con.sh
Created June 6, 2023 02:22
Show Gist options
  • Save summer20100514/9e27873f8f0dbd94bd82622df0f3ea2c to your computer and use it in GitHub Desktop.
Save summer20100514/9e27873f8f0dbd94bd82622df0f3ea2c to your computer and use it in GitHub Desktop.
Cron job that runs once every 10m and reset wlan0 if no internet connection is detected
#!/bin/bash
ping -c 1 google.com > /dev/null & wait $!
if [ $? != 0 ]; then
echo "$(date) Wifi down, resetting" >> /var/log/wifi.log
sudo ifdown wlan0 & wait $!
sudo ifup wlan0 & wait $!
else echo "$(date) Wifi up" >> /var/log/wifi.log
fi
# add to crontab
# */10 * * * * /home/<USER>/check_con.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment