Keep WiFi Alive on Raspberry Pi

So solving my connection problems to a Pi by turning off power savings didn’t work. I’m now using a crude but effective method where the Pi pings the gateway every 2 minutes.

Start by adding this script to /etc/



while :
    ping -c 1 ${PING_HOST} > /dev/null

This script works in an infinite loop, sending a single ping every 120 seconds. Call chmod 755 /etc/ to make it executable. Next, call it from /etc/rc.local:

/etc/ &

Which will run the script on the next reboot. Call /etc/ & in a shell to start it running, and you’re done.

So far, this seems to make ssh connections start immediately every time. I’d like to figure out what the actual problem is, but this will do.

Website Pin Facebook Twitter Myspace Friendfeed Technorati Digg Google StumbleUpon Premium Responsive

Tagged , , . Bookmark the permalink.

One Response to Keep WiFi Alive on Raspberry Pi

  1. scruss says:

    You could instead add an entry to the pi user’s crontab, something like:

    */2 * * * * ping -q -W 1 -c 1 > /dev/null

    This will attempt to ping your gateway every two minutes, with a timeout of one second so the command doesn’t hang if your network’s down.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.