Created
June 9, 2018 08:57
-
-
Save dizcza/806c8b831ed5e978901dea835f5334e8 to your computer and use it in GitHub Desktop.
Ubuntu restart WiFi service automatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# sudo crontab -e | |
# @reboot /home/dizcza/Programs/checkwifi.sh | |
# sudo update-rc.d cron defaults | |
/bin/sleep 30 | |
while true; do | |
/usr/bin/wget -T5 -q --spider google.com | |
code=$? | |
/bin/echo "$(date +'%D %H:%M:%S') code ${code}" >> /home/dizcza/checkwifi.log | |
if [ ${code} -ne 0 ]; then | |
/usr/bin/nmcli radio wifi off | |
/bin/sleep 5 | |
/usr/bin/nmcli radio wifi on | |
/bin/sleep 10 | |
/usr/sbin/service network-manager restart | |
/bin/echo "RESTARTED ${code}" >> /home/dizcza/checkwifi.log | |
fi | |
/bin/sleep 20 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment