Skip to content

Instantly share code, notes, and snippets.

@esdrasbeleza
Last active December 12, 2015 05:38
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 esdrasbeleza/4722683 to your computer and use it in GitHub Desktop.
Save esdrasbeleza/4722683 to your computer and use it in GitHub Desktop.
A script to verify if my connection is up and running. Put it to run in your crontab and you can have logs of your broadband internet connection, for example. Call $ check_connection.sh > output.log
#!/bin/sh
datetime=`date +%Y-%m-%d\ %H:%M:%S`
my_ip=`curl -s ifconfig.me`
exit_code=$?
if [ $exit_code == 0 ]; then
echo $datetime [ONLINE] $my_ip
else
echo $datetime [OFFLINE] Exit code: $exit_code
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment