Cron and multiple recipients

If you are using a maintainance user executing scheduled cronjobs, maybe you’ve found yourself needing to report the result of these jobs to different email addresses. Everyone knows for sure the MAILTO parameter, as explained in the crontab(5) manpages.

But maybe you don’t know that MAILTO is interpreted sequencially, when it’s found, so you can have different recipients in the same crontab, like in this example:


MAILTO="user1@domain.tld"
* * * * * echo "abc"

MAILTO=”user2@domain.tld”
* * * * * echo “dfe”

so user1 will get mailed with “abc” and user2 with “dfe”.
It works in the standard “cron” program, so for example you can use this tip in Debian or FreeBSD (and in other Unices to, I guess)

Advertisements

3 thoughts on “Cron and multiple recipients

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s