Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Can I do the following to change where mail goes for one specific crontab job in root's crontab (don't sent to root for Do Something job, just send to porklover):

# Make a hambone appear
* * * * * /scripts/hambone.pl

# Eat Ham
* * * * * /scripts/manga_ham.py

OLDMAILTO=$MAILTO

MAILTO=porklover.cramble.edu

#Do something
* * * * * /scripts/chown_abrahams_niece.sh

MAILTO=$OLDMAILTO
share|improve this question
add comment

1 Answer

No, you can't do it this way. Variable definitions in a crontab are global, and cron uses the same email address for all commands.

One workaround would be to use a local address and redirect based on the input.

Another method to send the output of a job to a different address is to do the sending manually. See How to pipe output from one process to another but only execute if the first has output? for various methods.

share|improve this answer
add comment

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.