I am trying to have my pi check my outside ip address every 5 minutes then compare it to the current ip stored in a text file. If the ip is different then I want it to update the text file, and email me. If the ip is the same then I want it to do nothing.
I have tried doing this with using crontab -e. I have also tried Sudo crontab -e, but have had no luck. Here is the command I am using in crontab.
0,15,30,45 * * * * pi /home/pi/scripts/updateip.sh &>/dev/null
The script I am running is located under the user name Pi (which I will be changing after I figure out how to do this), and it looks like this.
GNU nano 2.2.6 File: updateip.sh
#!/bin/sh
SUBJ="ip address has changed"
EMAIL="[email protected]"
ip1=""
ip2=""
read ip1 < ip.txt
ip2=$(wget -qO- ifconfig.me/ip)
if [ "$ip1" = "$ip2" ]
then
exit
else
echo "$ip2" > ip.txt
echo "$ip2" | mail -s $SUBJ $EMAIL
exit
fi
I am able to execute the script manually, but scheduling is another issue all together. I can confirm that I am receiving emails from the Pi. I have tried several other solutions found on this site, to no avail. thanks in advanced for your help.
EDIT I should note the issue appears to be the scheduled task just isn't running.
EDIT 2
The way I went about this was making it harder on me. I redid the whole solution. I followed a youtube video, and now my pi is working as desired. here is the link.Outgoing IP email tutorial