We help IT Professionals succeed at work.

Need to redirect Solaris 10 cron job failure e-mails to a Exchange 2003 mailbox.

netwrked
netwrked asked
on
1,537 Views
Last Modified: 2013-12-27
Currently, when a cron job fails on our Solaris 10 boxes, an e-mail gets sent to the owner of the cron job.  We have been trying to figure out a way to get those messages to go to a central mailbox on an external Exchange 2003 server.  We have over 50 servers and we want to be able to send consolidated alerts to one mailbox instead of having to check local mailboxes on each server.  Is there any way to tell a cron job to send failure e-mails to an account external to the box?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2007

Commented:
Hi,

You may need to specify the full path name of mailx tool. Also, you may set the env variable MAILTO in the script itself, and crontab will send the output as an email to that address:

e.g.

MAILTO=account@exchange.server
export MAILTO
CERTIFIED EXPERT
Top Expert 2007

Commented:
omarfarid.

Where are you getting your information from?  As far as I know, Solaris doesn't support the MAILTO variable.
CERTIFIED EXPERT
Top Expert 2007

Commented:
Hi,

Thank you Tintin for bringing this point :)

I checked the man page crontab for Solaris and it is not mentioned that you can set MAILTO. But, it says that it sends output (os stdout & stderr) to user by mail if  not redirected. Please see the link

If you do not redirect the standard output and standard error of your commands, any generated output or errors will be mailed to you.

My comment was based on the link below:

http://www.littletechshoppe.com/servers/extensions/cron/crontab_5.html

Thank you for the correction.

CERTIFIED EXPERT
Top Expert 2007

Commented:
Hi,

Typo: os -> of

Author

Commented:
Apparently, Solaris does not use the MAILTO variable, but this worked:

0 * * * * /path/to/script >/tmp/script.out 2>&1 || mailx -s "Cron failure" account@exchange.server </tmp/script.out

Thanks Tintin!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.