On debian 8.9

I want to check my ip address and send email every hour.

what I want to do is

1.Check my server ip address -> curl globalip.me2.Send ip address by email.

A. I know how to send mail in command line.B. I know how to setup crond.

However A requires manual response, so I don't know how to use A in B setting.

Is there any good way ??

share|improve this question

cron will send the output of a process to whatever it is told to in the MAILTO variable. You can execute curl or find your IP with any number of tools.

More importantly you need to make sure that your system can send mail and have it accepted wherever you are intending to read it. If you get a public IP via DHCP your ISP might block SMTP, test this with something simple like a cron entry to send the hostname or some such.

share|improve this answer

curl globalip.me | mail -s "my new ip" yourmail@example.com

Here -s "my new ip" is subject of the message.You may want to try man mail for more options like email for 'CC' or 'BCC' fields etc.

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.