Linux Step By Steps


The following information is distilled from Bill Parker and Joel Hammer to whom, all honour and glory.

THE problem is that cron, by it's nature, will invoke messages as often as every five minutes. The invoked program, not cron, rapidly fills up the all important /var/log/messages file with noise, AND, cron itself sends mail to the 'user'.

There are two good solutions to this 'problem'

Changing cron-invoked messages to a file of it's own

The solution is to change /etc/syslog.conf as follows:

1) change the following line FROM

*.info;news,mail,authpriv,auth.none       -/var/log/messages to 


*.info;cron,news,mail,authpriv,auth.none -/var/log/messages 

2) add the following line

cron.*                                     /var/log/cron

(Mike's note) The whitespace above is TABBED SPACE, NOT SPACES

3) restart cron and syslog daemons 

cd /etc/rc.d/init.d <enter>
./cron stop <enter>
./syslog stop <enter>
./syslog start <enter>
./cron start <enter>

Joel Hammer


Cron sends unwanted mail to user's mailbox.


If a program run by cron produces output, either to standard output or to standard error, that output doesn't get sent to the console and is not logged. Rather, it is mailed to the owner of the cronttab file which contains the command. For example, this command:

*/10 * * * * /usr/bin/fetchmail

in the crontab file of user "fred" will send a mail message to fred every ten minutes. This is because fetchmail outputs some routine information each time it runs above and beyond any information sent to syslogd.

There are three ways to stop or curtail this behavior:

1. At the top of the crontab file, place the following command:

MAILTO="" (That's a null or just two quotes back to back)

This will suppress all mail from this crontab file.

2. Redirect the output as follows:

/usr/bin/fetchmail >& /dev/null

This should suppress all output. You might get creative and just suppress standard output but let standard error be mailed. I haven't tried this but the following might work:
/usr/bin/fetchmail 1> /dev/null

3. Fetchmail has a special command for ~.fetchmailrc to send all output to syslogd instead of to the console. Place set syslog in /home/fred/.fetchmailrc

I have tried all three methods and all work. However, with the third method, I still get a small number of emails from cron about fetchmail. I am not sure why. I suppose I don't understand fetchmail well enough.