[CentOS] use of MAILTO variable in crontab

Rudi Ahlers Rudi at SoftDux.com
Thu Jul 14 17:16:16 UTC 2011


On Wed, Jul 13, 2011 at 9:10 PM, James B. Byrne <byrnejb at harte-lyne.ca> wrote:
>
> On Wed Jul 13 15:03:40 EDT 2011, Michael Best mbest at pendragon.org
>  wrote:
>> Like this:
>>
>> MAILTO=testaddr at harte-lyne.ca
>> 30 2 * * * echo "this should be mailed"
>
> That sets MAILTO for the entire crontab does it not?  I want to set
> MAILTO differently for specific crontab entries.  Is that possible?
> How is it done?  Or do I have to pipe stuff to /usr/bin/mail
> explicitly?
>



Easy:


MAILTO="root"
30 2 * * * echo "this should be mailed to root"
MAILTO="james at harte.x.x"
30 4 * * * echo "this should be mailed to James"
MAILTO="bob"
30 5 * * * echo "this should be mailed to Bob"
MAILTO=""
30 6 * * * echo "this should be mailed to no-one"


-- 
Kind Regards
Rudi Ahlers
SoftDux

Website: http://www.SoftDux.com
Technical Blog: http://Blog.SoftDux.com
Office: 087 805 9573
Cell: 082 554 7532



More information about the CentOS mailing list