2009-02-21

cron - email recipient other the root

We all use cron (this part of the world, "open source" world). But some times we wouldn't want to send the output or error messages to root, or anyone in /etc/aliases. Only to an email we trust or a normal user on the server. Cron is flexible. Thanks Vixie, Paul Vixie.


Problem :
Status of cron jobs are often sent to root of the server. Is there a way to only send to another email address other then root? or other then the aliases in /etc/aliases?


Solution :
use "MAILTO" in variable in the first line of crontab.
e.g.
<start of file>

MAILTO=otheruser@domain.com 

01 01 * * * /usr/sbin/ntpdate 0.pool.ntp.org

01 05 * * * some-other-command

01 06 * * * another-command

<end of file>

AdiĆ³s !!!

No comments: