Skip to content

Instantly share code, notes, and snippets.

@bobbzorzen
Created September 24, 2014 20:00
Show Gist options
  • Save bobbzorzen/a1c229d97daf329eeb78 to your computer and use it in GitHub Desktop.
Save bobbzorzen/a1c229d97daf329eeb78 to your computer and use it in GitHub Desktop.
#!/bin/bash
function child()
{
while true; do
filename='currentip.txt'
oldIp=`cat $filename`
currentIp=`curl http://bot.whatismyipaddress.com/`
if [ $oldIp != $currentIp ]
then
echo "$(date)\tIp address has changed, sending mail. (Old: $oldIp | New: $currentIp)" >> mailerlog.log
php sendMailTest.php $currentIp
echo $currentIp > $filename
fi
sleep 12h
done
}
child&
kill $$ #Kill parent and leave child running
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment