I would like to send an email to [email protected] instead of default system root user for crond service on a Linux or Unix-like system. How do I change the email settings under crontab file on a Linux or Unix-like systems?
A crontab file contains instructions to the cron daemon. It wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. When executing commands, any output is mailed to the owner of the crontab or to the user named in the MAILTO environment variable in the crontab, if such exists. The syntax is:[donotprint][/donotprint]
name = value
Where the spaces around the equal-sign (=) are optional, and any subsequent non-leading spaces in value will be part of the value assigned to name. The value string may be placed in quotes (single or double, but matching) to preserve leading or trailing blanks. The value string is not parsed for environmental substitutions, thus lines like:
PATH = $HOME/bin:$PATH
will not work as you might expect.
In addition to LOGNAME, HOME, and SHELL, cron will look at MAILTO if it has any reason to send mail as a result of running commands in “this” crontab. If MAILTO is defined (and non-empty), mail is sent to the user so named. First open your crontab file:
# vi /etc/crontab
$ crontab -e
To send email to [email protected], enter:
If MAILTO is defined but empty (MAILTO=””), no mail will be sent.
Otherwise mail is sent to the owner of the crontab.