LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-06-2008, 07:40 AM   #1
akudewan
Member
 
Registered: Apr 2004
Location: India
Distribution: Ubuntu
Posts: 364

Rep: Reputation: 31
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?
 
Old 07-06-2008, 08:54 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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.
 
Old 07-06-2008, 09:51 AM   #3
akudewan
Member
 
Registered: Apr 2004
Location: India
Distribution: Ubuntu
Posts: 364

Original Poster
Rep: Reputation: 31
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
 
1 members found this post helpful.
Old 07-06-2008, 03:41 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by akudewan View Post
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.
 
Old 07-06-2008, 04:37 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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.
 
Old 07-06-2008, 09:09 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by Mr. C. View Post
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.
 
Old 07-07-2008, 09:29 AM   #7
akudewan
Member
 
Registered: Apr 2004
Location: India
Distribution: Ubuntu
Posts: 364

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by Mr. C. View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP not logging via syslog-ng fukawi2 Linux - Server 2 07-02-2008 04:49 AM
syslog-ng is not logging coreno Linux - Software 4 09-08-2007 01:13 PM
Logging/syslog s0n|k Linux - Newbie 2 03-13-2006 07:36 PM
Syslog logging Cron logins rhoekstra Fedora 4 02-17-2005 02:45 AM
syslog running but not logging tantric Linux - Security 1 10-15-2003 07:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration