102010

External IP Address Recording Script Andrew Mallett | Updated Sept 2017

Following on from the External IP Address Monitor, the following script will record changes to a user's external IP Address into a clear text file.

cd /sc/extip
rm /sc/extip/ip.php
wget http://shell-scripts.com/ip.php
echo `/bin/date +%Y-%m-%d` `/bin/cat /sc/extip/ip.php` >> /sc/extip/ip_record

The above script firstly changes to a (previously created) directory called extip. On the second line, the previous day's result, ip.php is firstly deleted. The script then Wgets a new ip.php..

Finally the echo command is used to echo the current date and then the contents of the current ip.php file (the current IP Address) and appends the result to a log record file called ip_record.

The task is automated at two minutes past midnight via a new crontab entry..

02 00 * * * /sc/scripts/extip.sh

Remember to use full paths to all files in scripts which will run via cron.

 

Back