Configuring crontab mail destinations with MAILTO


When scripts executing from cron write to stdout or stderr, the results are emailed to the user the job is running in the context of. One way to control where the mail is sent is by adding a “MAILTO” line to the top of the crontab entry for the user that is running the cron job. Here is an example:

$ crontab -l
MAILTO=matty

Each time this job runs, the user matty will get emailed with the results of the script. You can also use /etc/aliases to assist with this on a global scale, but sometimes that isn’t an option.

This article was posted by Matty on 2006-12-29 02:40:00 -0400 -0400