Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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
share|improve this answer
    
thanks , where\how do I write this?? , in which language is it? –  david Jan 3 '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. –  user8290 Jan 3 '13 at 20:51

use crontab

 crontab -e

and then add below lines

 MAILTO="your@emailaddress"
 0 * * * * wget -q -t 5 -O - "http://automation.whatismyip.com/n09230945.asp"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.