tags:

views:

27

answers:

2

I have 3 jobs in my crontab. I want to recieve emails if only 1 of them fails and not for other two. Is there any way to restric emails to one type of cronjob?

+3  A: 

Redirect the output of the two you don't care about to /dev/null if you don't ever want to see the output or to some file if you do.

Blrfl
And the standard error.
mobrule
A: 

Your cron likely supports this:

# This job produces mail.
* * * * * echo Hello

# These jobs do not.
MAILTO=
* * * * * echo Foo
* * * * * echo Bar
Mark Edgar
Isn't MAILTO= common to all the task in a same crontab file? If the first task produces the email where is the email id specified for that job? I thought MAILTO= is common to all the tasks in crontab file? Or can we have multiple MAILTO='s in a crontab file?
Fonda
Depends on your crontab. Does yours support it? Mine does.
Mark Edgar