Skip to content

Instantly share code, notes, and snippets.

@imsurinder90
Last active July 24, 2018 10:40
Show Gist options
  • Select an option

  • Save imsurinder90/c676f08ae1053aaf5430ea4f13d09d9a to your computer and use it in GitHub Desktop.

Select an option

Save imsurinder90/c676f08ae1053aaf5430ea4f13d09d9a to your computer and use it in GitHub Desktop.

Revisions

  1. imsurinder90 created this gist Jul 24, 2018.
    24 changes: 24 additions & 0 deletions restart_wifi.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    create a new file /usr/local/bin/restart_wifi.sh
    and put below script in it.

    ping -c4 192.168.1.1 > /dev/null

    if [ $? != 0 ]
    then
    echo "No network connection, restarting wlan0"
    sudo systemctl daemon-reload
    sleep 5
    sudo systemctl restart dhcpcd
    fi

    then

    Now make it executable:
    sudo chmod 775 /usr/local/bin/restart_wifi.sh

    Then add it to a crontab

    */5 * * * * /usr/bin/sudo -H /usr/local/bin/restart_wifi.sh >> /dev/null 2>&1

    This command will check every 5 minute if wifi is stopped or not.