LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   disable cron from logging to syslog (https://www.linuxquestions.org/questions/linux-general-1/disable-cron-from-logging-to-syslog-653876/)

akudewan 07-06-2008 07:40 AM

disable cron from logging to syslog
 
Hi,

I have a cron job that runs every 10 minutes. Problem is that it clutters my /var/log/syslog file. Can someone help me with a way of disabling this logging ?

So far I have tried the following:

1) Redirected the output of the command to /dev/null. (This solved the problem of the output being mailed to me every time)
Code:

0,10,20,30,40,50 * * * * /usr/local/bin/keeponline.sh >> /dev/null 2>&1
2) Edited /etc/syslog.conf and commented out the lines containing 'cron'. This is what the file looks like:
Code:

#  /etc/syslog.conf    Configuration file for syslogd.
#
#                      For more information see syslog.conf(5)
#                      manpage.

#
# First some standard logfiles.  Log by facility.
#

auth,authpriv.*                /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                        /var/log/cron.log
daemon.*                        -/var/log/daemon.log
kern.*                          -/var/log/kern.log
lpr.*                          -/var/log/lpr.log
mail.*                          -/var/log/mail.log
user.*                          -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info                      -/var/log/mail.info
mail.warn                      -/var/log/mail.warn
mail.err                        /var/log/mail.err

# Logging for INN news system
#
news.crit                      /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                    -/var/log/news/news.notice

#
# Some `catch-all' logfiles.
#
*.=debug;\
        auth,authpriv.none;\
        news.none;mail.none    -/var/log/debug
*.=info;*.=notice;*.=warn;\
        auth,authpriv.none;\
#      cron,daemon.none;\
        mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                        *

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#      news.=crit;news.=err;news.=notice;\
#      *.=debug;*.=info;\
#      *.=notice;*.=warn      /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
#
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
daemon.*;mail.*;\
        news.err;\
        *.=debug;*.=info;\
        *.=notice;*.=warn      |/dev/xconsole

However, there's entries in my syslog every 10 minutes:
Code:

Jul  6 17:30:01 ranjandesk /USR/SBIN/CRON[13450]: (akudewan) CMD (/usr/local/bin/keeponline.sh >> /dev/null 2>&1)
Jul  6 17:40:01 ranjandesk /USR/SBIN/CRON[13707]: (akudewan) CMD (/usr/local/bin/keeponline.sh >> /dev/null 2>&1)
Jul  6 17:50:01 ranjandesk /USR/SBIN/CRON[13984]: (akudewan) CMD (/usr/local/bin/keeponline.sh >> /dev/null 2>&1)

Can I make this particular cron job not log to syslog?

trickykid 07-06-2008 08:54 AM

You need to edit the line that is outputing *.* to your syslog log file:

Code:

*.*;auth,authpriv.none          -/var/log/syslog
It was the line above your cron log you already edited. I wouldn't totally comment it out, customize it to log what you want. man syslog.conf and or syslog for more details on logging levels, etc.

akudewan 07-06-2008 09:51 AM

Thanks a million trickykid! I managed to solve the problem simply by changing the *.* line to look like this:
Code:

*.*;auth,authpriv,cron.none            -/var/log/syslog

trickykid 07-06-2008 03:41 PM

Quote:

Originally Posted by akudewan (Post 3205583)
Thanks a million trickykid! I managed to solve the problem simply by changing the *.* line to look like this:
Code:

*.*;auth,authpriv,cron.none            -/var/log/syslog

No problem.

Mr. C. 07-06-2008 04:37 PM

Why not make your keeponline script do its thing in a loop, sleep for N seconds, and then do its thing again?

Then, just start it either manually, or via your startup scripts.

Disabling cron syslog output will end up biting you some time.

trickykid 07-06-2008 09:09 PM

Quote:

Originally Posted by Mr. C. (Post 3205915)
Why not make your keeponline script do its thing in a loop, sleep for N seconds, and then do its thing again?

Then, just start it either manually, or via your startup scripts.

Disabling cron syslog output will end up biting you some time.

Well, he could turn the cron logging back on that he initially disabled. I don't like the same thing logging to multiple places, kind of annoying.

akudewan 07-07-2008 09:29 AM

Quote:

Originally Posted by Mr. C. (Post 3205915)
Why not make your keeponline script do its thing in a loop, sleep for N seconds, and then do its thing again?

Then, just start it either manually, or via your startup scripts.

Disabling cron syslog output will end up biting you some time.

Hmm...that makes a lot of sense. I think I'll implement this when I have some free time on my hands.

Thanks for the suggestion.


All times are GMT -5. The time now is 04:12 AM.