Skip to content

Instantly share code, notes, and snippets.

@wb14123
Last active March 28, 2016 12:09
Show Gist options
  • Save wb14123/93b8ec085b5772d92493 to your computer and use it in GitHub Desktop.
Save wb14123/93b8ec085b5772d92493 to your computer and use it in GitHub Desktop.
Send you an Email while the IP has changed
#!/bin/sh
# Install postfix in order to send Email
# Put this script in /etc/cron.hourly can test if the IP has changed per hour.
# Change the Email "[email protected]" to your Email
ip_file='/tmp/cur_ip'
email='[email protected]'
last_ip=`cat $ip_file`
cur_ip=`curl ifconfig.me`
if [ "$cur_ip" != "" ] && [ "$last_ip" != "$cur_ip" ]; then
echo $cur_ip > $ip_file
echo "IP has changed to $cur_ip"
echo "Office IP has changed to $cur_ip" | mail -s "Office IP Changed" $email
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment