No MTA installed, discarding output
By default, cron collects whatever a job writes to stdout or stderr and tries to email it when the job finishes.
What causes this error
If you see (CRON) info (No MTA installed, discarding output) in syslog, a job printed output and Debian or Ubuntu cron could not find /usr/sbin/sendmail to mail it. The output was discarded. That line is only written for a job that printed something, and cron only looks for /usr/sbin/sendmail. cronie (Red Hat, Fedora, and cronie installed elsewhere) does not log this sentence. If /usr/sbin/sendmail is missing when crond starts, cronie logs Syslog will be used instead of sendmail. and writes the job output to the cron log as CMDOUT lines. An empty MAILTO does not stop those lines.
This is not a problem with your cron job itself, and does NOT mean that your cron job is failing.
How to fix No MTA installed errors
There are a few ways to deal with this:
Keep the output, which also stops the mail attempt. Cron only tries to send mail when the job wrote something. Redirect both streams, as described in How to save cron job output to a log file:
*/5 * * * * python /home/crons/send-updates.py >> /home/crons/send-updates.log 2>&1To throw the output away on purpose, use
> /dev/null 2>&1in that same position.Install an MTA such as postfix. On Ubuntu:
sudo apt-get install postfixIf you select the local install, mail stays on this machine. The mailbox path is
/var/mail/plus the user who owns the crontab:sudo tail -f /var/mail/usernameIf you don't care about cron emails, disable them. Add this at the top of the crontab:
MAILTO=""An empty
MAILTOtells Debian and Ubuntu cron not to send mail, so this syslog line stops. The output is still discarded. On cronie, after the syslog fallback, the output is still written asCMDOUTlines.MAILTOis covered in crontab environment variables.You can leave the line in syslog. It is not a fatal error, and it does not change the job's exit status. It is written again every time that job prints something.
cronitor exec does not hide this message. The wrapper passes the command's output through, and cron still tries to mail it. The wrapper also uploads that output unless you pass --no-stdout before the monitor key:
*/5 * * * * cronitor exec --no-stdout monitor-key python /home/crons/send-updates.py >> /home/crons/send-updates.log 2>&1
The redirect keeps a copy on disk and gives cron nothing to mail. The command string is still sent when you use --no-stdout, so keep secrets out of the arguments. See Wrap an executable without uploading its output for what is uploaded.
Want alerts if your cron jobs stop working?
Monitor your cron jobs with Cronitor to easily collect output, capture errors and alert you when something goes wrong.