Skip to content

Instantly share code, notes, and snippets.

@drkmullins
Last active December 16, 2015 19:00
Show Gist options
  • Save drkmullins/5482398 to your computer and use it in GitHub Desktop.
Save drkmullins/5482398 to your computer and use it in GitHub Desktop.
Checks my macbook's Wi-Fi every 5 seconds. If it's down, it restarts the adapter. I use it when my Wi-Fi signal is flaky and my macbook is having issues staying connected.
#!/bin/bash
# Checks my mac's Wi-Fi every 5 seconds.
# If it's down, restart the adapter.
while :
do
if [ $(networksetup -getinfo Wi-Fi | grep -c 'IP address:') = '1' ]
then
$(networksetup -setairportpower en1 off)
$(networksetup -setairportpower en1 on)
sleep 5
echo "Restarting Wi-Fi at $(date)."
fi
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment