cron polluting messages
Hi, I've digesting this subject from the list, but still can not prevent cron from writing in /var/log/messages. Specially if it runs every couple of minutes, i don't to see it in my log file, (unless it fails) The original line ended in &>/dev/null So the output from the script is sent to limbo. But i dont want even to see that it is run. So according to some suggestions i expended it to &>/dev/null MAILTO="" And added to /etc/sysconfig/cron: MAILTO="" But this seems to be not enough.. Kind regards, Hans -- pgp-id: 926EBB12 pgp-fingerprint: BE97 1CBF FAC4 236C 4A73 F76E EDFC D032 926E BB12 Registered linux user: 75761 (http://counter.li.org)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2006-11-05 at 15:27 +0100, Hans Witvliet wrote:
I've digesting this subject from the list, but still can not prevent cron from writing in /var/log/messages.
CRONTAB(5) ... If the uid of the owner is 0 (root), he can put a "-" as first character of a crontab entry. This will prevent cron from writing a syslog message about this command getting executed. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFFTgN6tTMYHG2NR9URAiipAJ9W7WP00CQP7f+eJ7ggTrtjQ57F4wCfe6N6 6CxonRP1/2wdt7WY77Vo34o= =tnOA -----END PGP SIGNATURE-----
* Hans Witvliet
But i dont want even to see that it is run. So according to some suggestions i expended it to &>/dev/null MAILTO=""
And added to /etc/sysconfig/cron: MAILTO=""
But this seems to be not enough..
for information only as Carlos' answer provides a better result (imo): the 'MAILTO' requires a character, space, rather than nothing, "", ie: MAILTO=" " from 'man 5 crontab': In addition to LOGNAME, HOME, and SHELL, cron(8) 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. If MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the owner of the crontab. This option is useful if you decide on /bin/mail instead of /usr/lib/sendmail as your mailer when you install cron -- /bin/mail doesn't do aliasing, and UUCP usually doesn't read its mail. -- Patrick Shanahan Registered Linux User #207535 http://wahoo.no-ip.org @ http://counter.li.org HOG # US1244711 Photo Album: http://wahoo.no-ip.org/gallery2
On 2006-11-05 08:27, Hans Witvliet wrote:
Hi,
I've digesting this subject from the list, but still can not prevent cron from writing in /var/log/messages. Specially if it runs every couple of minutes, i don't to see it in my log file, (unless it fails)
The original line ended in &>/dev/null So the output from the script is sent to limbo.
But i dont want even to see that it is run. So according to some suggestions i expended it to &>/dev/null MAILTO=""
And added to /etc/sysconfig/cron: MAILTO=""
But this seems to be not enough..
Kind regards, Hans
If it is a root cron task, Carlos has already said how to get rid of the log entries. Otherwise.... You can log all cron messages to a dedicated cron log. In /etc/syslog-ng/syslog-ng.conf.in, find the following lines and uncomment the last two: # # Cron-messages in one file: # #destination cron { file("/var/log/cron"); }; #log { source(src); filter(f_cron); destination(cron); }; The run SuSEconfig to add the change to the real config file and restart the syslog daemon. Note: you don't want to change /etc/syslog-ng/syslog-ng.conf directly, because the next time SuSEconfig gets hold of it, it will use the .in file as a base, and wipe out your change. This won't get rid of the log entries every minute or so, but it will move them out of /var/log/messages. You could hack the syslog-ng config file to ignore this particular cron task (that is essentially how the firewall log entries get put into a dedicated firewall log), but that's a bit of work that I don't properly understand right now.
participants (4)
-
Carlos E. R.
-
Darryl Gregorash
-
Hans Witvliet
-
Patrick Shanahan