1

I have a computer that every 5 hours change is IP I want to make a script that will run every hours with this command -

wget -q -t 5 --output-document=- "http://automation.whatismyip.com/n09230945.asp"

and send me the ip that he is getting. how do I do this? and is it possible to do? thanks.

Jorge Castro
  • 71,754
david
  • 11
  • 1
  • 2

2 Answers2

1

Make sure the remote system can send mail. Create a script in cron's hourly folder.

sudo -e /etc/cron.hourly/ipcheck

The contents of the file:

#!/usr/bin/env bash
wget -q -t 5 --output-document=- "http://automation.whatismyip.com/n09230945.asp" | mailx -s "External IP Address" me@mydomain.com

Set the script to executable:

sudo chmod 0755 /etc/cron.hourly/ipcheck
  • thanks , where\how do I write this?? , in which language is it? – david Jan 03 '13 at 20:47
  • @david Um... sudo -e invokes the default editor that will create a new file (ipcheck) in the /etc/cron.hourly/ directory. It's a BASH shell script. –  Jan 03 '13 at 20:51
0

use crontab

 crontab -e

and then add below lines

 MAILTO="your@emailaddress"
 0 * * * * wget -q -t 5 -O - "http://automation.whatismyip.com/n09230945.asp"
neo
  • 219
  • 2
  • 6