How to send the output from a cronjob to multiple e-mail addresses?

Solution 1:

It may differ depending exactly which cron daemon package you use, but this is from the manpage of Vixie Cron on Ubuntu Hardy:

If MAILTO is defined (and non-empty), mail is sent to the user so named. MAILTO may also be used to direct mail to multiple recipients by separating recipient users with a comma. If MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the owner of the crontab.

If you're not using Vixie Cron, or aren't sure, try the manual page for the crontab file: man 5 crontab

Example

MAILTO="[email protected],[email protected]"

Solution 2:

As an alternative to the above answers, you can send email to a single address which is a mail group or distribution list. This works especially well if you manage multiple servers since it is easier to manage addresses on your mail server rather than in crontab of each individual machine.


Solution 3:

One solution might be a .forward file on that user account which sends mail to the appropriate addresses.

Tags:

Email

Cron