Operating System - HP-UX
1830362 Members
2513 Online
110001 Solutions
New Discussion

MAILTO equivalent in crontab?

 
Clay Jones_2
Frequent Advisor

MAILTO equivalent in crontab?

I've learned to love the "MAILTO" environement variable as it emails STDOUT and STDERR (assuming they're not redirectred) to the recipient specified. Example cron file:

MAILTO=user@host.com
0 0 * * * /some/command

STDOUT and STDERR from /some/command would be emailed to user@host.com in this example.

I get an error from cron on HPUX 11 about syntax, probably because of the @ sign. Is there an equivalent way to email STDOUT and STDERR from cron jobs to an email address?

Thanks...
3 REPLIES 3
Michael Schulte zur Sur
Honored Contributor

Re: MAILTO equivalent in crontab?

Hi,

have you tried with
0 0 * * * /some/command 2>&1 | mail user@host.com
?

greetings,

Michael

Clay Jones_2
Frequent Advisor

Re: MAILTO equivalent in crontab?

Hi,

Good suggestion, and that's probably the cleanest way short of MAILTO. I was hoping something similar to MAILTO existed to save myself the trouble of appending that string.

Thanks for the suggestion and your help.

Clay
Michael Schulte zur Sur
Honored Contributor

Re: MAILTO equivalent in crontab?

Hi,

your suspiccions seem to be right. Look here:
http://www.rt.com/man/crontab.5.html
It seems, crontab supports only local mails.
I just have this thought, you could create a .mailrc and you may use MAILTO and distribute it to a mail list.

what do you think?

Michael