Saturday, September 23, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  2] [ 0]  / answers: 1 / hits: 4085  / 2 Years ago, sun, july 4, 2021, 7:00:16

I'm using DNSExit on my Ubuntu server (Natty 11.04) and have installed the ipUpdate rpm file and did an apt-get install for chkconfig to enable the ipUpdate.

I'd like to get an email whenever the IP address changes, so that I can SSH into the box using PuTTY (because I can't unless I know the current IP address).

The current IP address is stored in /tmp/dnsexit-ip.txt, and I'd like to, whenever that file changes, to mail the contents of that file and the contents of /var/log/dnsexit.log (which contains a history of the IP changes) to my email address.

How can I accomplish this task? I'm thinking that a cronjob will be the solution, but I'm not sure how to do this.

More From » cron



Install sendEmail. It's a lightweight, command line SMTP email client. We'll use it to send emails from a script, using a Gmail account.

sudo apt-get install sendemail libio-socket-ssl-perl libnet-ssleay-perl

Create the script

Create a file named "" somewhere, for example in a "Scripts" directory in your home folder; make it executable, and open it up for editing.

mkdir -p ~/Scripts && touch ~/Scripts/ && chmod a+x ~/Scripts/ && gedit ~/Scripts/

Insert the following text in the file:


# Modify the following values!

SENDERNAME="Computer" # This is the name that will show in the 'From' field. Purely esthetic.
RECIPIENTNAME="Your Name" # This is the name that will show in the 'To' field. Also purely esthetic.
GMAILADDRESS="[email protected]" # This is your Gmail address.
GMAILUSER="someemail" # This is your Gmail username, without the '' part.
GMAILPASS="password" # This is your Gmail password.

# You can stop modifying here


if [[ $(find $DIR -mmin -2 -name $CURIP) ]];
echo "$CURIP has been modified in the last two minutes."
# Send an email
sendemail -u "IP Address" -m "IP address has changed!" -f "$SENDERNAME <$GMAILADDRESS>" -t "$RECIPIENTNAME <$GMAILADDRESS>" -s $SMTPSERVER -xu $GMAILUSER -xp $GMAILPASS -a $DIR$CURIP $IPLOG

Once that's done, save and close the file.

Run the script periodically

We'll run this script every two minutes. Open up your crontab.

crontab -e

Add the following line to the bottom of the file:

*/2 * * * * bash ~/Scripts/

You're done!

If all goes well, you should now get email updates when the IP address of your machine changes.

[#38116] Monday, July 5, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 317
Total Questions: 89
Total Answers: 106

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago