[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1359
  • Last Modified:

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

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?
0
netwrked
Asked:
netwrked
  • 3
  • 2
1 Solution
 
TintinCommented:
You could either setup aliases in /etc/aliases, eg:

user1:account@exchange.server
user2:account@exchange.server

or change your cronjobs to be something like:

0 * * * * /path/to/script >/tmp/script.out 2>&1 || mailx -s "Cron failure" account@exchange.server </tmp/script.out
0
 
omarfaridCommented:
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
0
 
TintinCommented:
omarfarid.

Where are you getting your information from?  As far as I know, Solaris doesn't support the MAILTO variable.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
omarfaridCommented:
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.

0
 
omarfaridCommented:
Hi,

Typo: os -> of
0
 
netwrkedAuthor 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!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now