"(CRON) info (No MTA installed, discarding output)" error in the syslog
I have a fresh install of Ubuntu 12.04.1 LTS an a number of servers.
I have not added any cron jobs or edited my crontab on those servers, however, at around the same time for each machine, I get a 75% CPU spike and the following info in my syslog at the time of the spike:
CRON[8380]: (CRON) info (No MTA installed, discarding output)
I have mono-complete installed and am running a service stack webserver.
What is the best way for me to stop this from happening? I would like to be able to remove the CPU spike.
Linux uses mail for sending notifications to the user. Most Linux distributions have a mail service including an MTA (Mail Transfer Agent) installed. Ubuntu doesn't though.
You can install a mail service, postfix for example, to solve this problem.
sudo apt-get install postfix
Or you can ignore it. I don't think the inability of cron to send messages has anything to do with the CPU spike (that's linked to the underlying job that cron is running). It might be safest to install an MTA and then read through the messages (mutt
is a good system mail reader).
This happens because your cron jobs are producing output and then the cron daemon tries to email that output to you (i.e. root). If you don't need that output, the easiest way to solve this is to discard it at the crontab:
sudo crontab -e
and add >/dev/null 2>&1
to every job:
* * * * * yourCommand >/dev/null 2>&1
In my case, the message was hinting at a permissions problem with the bash script, but I couldn't see it until I installed an MTA.
As suggested I ran:
sudo aptitude install postfix
I chose "Local" during setup and after running the cron job again:
sudo tail -f /var/mail/<user>
In my case I replaced
<user>
with "root".
I was then able to see the error output related to permissions.
As stated in an earlier answer, this happens because your cron jobs are producing output, and then the cron daemon tries to email that output to you. If you don’t want to (or can’t) install an MTA, but you want to see the output, you can redirect the output of the cron job to a log file. Edit your crontab file with
crontab -e
(use sudo
if the issue is with root’s crontab)
and add >> /some/log/file 2>&1
after every command, like this:
0 3 * * * cmd >> /some/log/file 2>&1
If there are multiple commands on a line,
separated by ;
, &&
or ||
,
you should do the above for each command, like this:
0 3 * * * cmd1 >> /some/log/file 2>&1; cmd2 >> /some/log/file 2>&1
or group them, like this:
0 3 * * * (cmd1; cmd2) >> /some/log/file 2>&1
If you want to ignore stdout and capture only stderr,
use > /dev/null 2>> /some/log/file
instead.
Put the log file wherever you want — your home directory,
/var/log
, or even /tmp
if you’re sure you won’t need to keep it.
Then look at the log file after the job runs.