I’ve been using Linux for over a decade. In fact, the original blog that this one forked off from was hosted on a linux machine in my bedroom. However, I am still, after a decade, a bit of a novice.

So for the sake of Googlers out there that might be looking to do what I was looking to do, here’s how to make a simple script that will check your public IP address and add it to a log. (A couple friends more knowledgable in Linux helped me with this when Google wasn’t giving me the results I needed).

First, create a shell script and put the following in it:

#!/bin/sh

IP=`curl http://automation.whatismyip.com/n09230945.asp`
DATE=`date`

echo "$IP - $DATE" >> iplog.txt

I put mine in my home folder. The log file will be created the first time you run it, and will be in the same folder as the script.

To run this every morning at 1:00am, create a file in the /etc/cron.d folder and put this in it:

0 1 * * * andy sh /home/andy/ipcheck.sh

Of course you’ll want to change “andy” to your username, “/home/andy/ipcheck.sh” to the path and filename of your script.

Why would you want to do this? Who knows, but I did because I was curious to see how often the dynamic IP address for my home network changes. It doesn’t change often (if ever), but the only way to really know is to log it.