Skip to content

Instantly share code, notes, and snippets.

@dustincys
Created March 13, 2016 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustincys/6ee90147e425b71aa097 to your computer and use it in GitHub Desktop.
Save dustincys/6ee90147e425b71aa097 to your computer and use it in GitHub Desktop.
reboot router automatically
#!/bin/bash
retval=1
testInternet(){
sleep 10
wget -q --tries=10 --timeout=20 --spider http://www.baidu.com
date
if [[ $? -eq 0 ]]; then
retval=1
echo "Online!"
else
retval=0
echo "Offline!"
fi
}
while [ "$retval" == 1 ]; do
testInternet
if [ "$retval" != 1 ]
then
curl --user 1:1 http://192.168.1.1/userRpm/SysRebootRpm.htm?Reboot=Reboot >/dev/null 2>&1
sleep 180
fi
retval=1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment