Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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