LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-08-2004, 11:45 PM   #1
guyk
LQ Newbie
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: Debian (Woody)
Posts: 9

Rep: Reputation: 0
Unhappy Turn off logging for specific cron job


Hi,

We have a system which has been giving us some grief, so we've written a perl script to check the status of the system and bring it back up if it has stopped running. I've set up a cron job to execute this script every 5 minutes, but unfortunately the cron log now gets a new line every time this script is run, and I can see that this is going to become a problem if I leave it much longer.

Is there any way you can turn off logging for particular cron jobs? I know I could rotate the log, or clear it out on a regular basis, but this doesn't resolve the problem I have with unnecessary information being logged to the cron log file.

All help would be greatly appreciated!

Thanks,
Guy
 
Old 09-09-2004, 12:29 AM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Sorry Guy, I don't think this is possible!
You could always hardcode an exception into the source code for cron, which is a horrible horrible solution.

Another horrible hack of a solution might be to create a FIFO, configure syslog to log cron data there, and have a process at startup like this:

grep -vi "my.specific.job" fifoname > /var/log/syslog &

Yuck! But it would work...
 
Old 09-09-2004, 12:30 AM   #3
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
err, I meant /var/log/cron.log obviously...
 
Old 09-09-2004, 05:15 AM   #4
guyk
LQ Newbie
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: Debian (Woody)
Posts: 9

Original Poster
Rep: Reputation: 0
Hmmm...if it was really important I might consider those options, but it's not really a big issue. I might go with plan B, which is write a script to strip out those lines on a weekly basis or something like that. I was hoping there'd be an easier way though...

Thanks anyway mate
 
Old 09-10-2004, 06:56 PM   #5
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
There was another thread similar to this that I read recently. The suggestion I liked was to just send the output of the cronjob to /dev/null. Example:
* * * * * /usr/bin/example > /dev/null

I don't know if this works, but I like the idea. (I'm assuming something in the script is outputting a newline)
 
Old 09-11-2004, 03:48 AM   #6
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
gd2shoe: I think this is to stop the cron job mailing you every time it runs - cron sends a line to syslog every time it starts a job regardless of output.
 
Old 09-13-2004, 08:17 PM   #7
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
Thanks for the feedback. Maybe the newline is being sent as standard error (though it makes no sense as to how such would get into the code). Again, just speculating.
 
Old 10-23-2004, 02:00 AM   #8
Kahless
Member
 
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503

Rep: Reputation: 30
the dev/null idea does work, and is default in the crontab in slackware.
 
Old 10-23-2004, 08:18 AM   #9
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
OK, reading comprehension is the order of the day here.

Cron job executes - if there is output, the output is emailed to the user that started the job.

Independent of job's output, every time cron runs a job, it sends a message through the syslog daemon.

Routing output to /dev/null has no effect on the logging facility. Now, re-read the original post:

Quote:
but unfortunately the cron log now gets a new line every time this script is run
.

So yes, routing the output of any job to /dev/null will stop it producing output. It will not solve the problem specified - he is not talking about a newline character, but a new entry in the system logfiles.
 
Old 10-23-2004, 09:52 AM   #10
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
Hi, I've had a cron running every "6" minutes for years. Here are the sizes of my log files. Help me understand what your specific problem is then.
[root@entropy log]# ls -la /var/log |grep cron
-rw------- 1 root root 195323 Oct 23 08:50 cron
-rw------- 1 root root 219143 Oct 17 04:02 cron.1
-rw------- 1 root root 219665 Oct 10 04:01 cron.2
-rw------- 1 root root 219880 Oct 3 04:01 cron.3
-rw------- 1 root root 219833 Sep 26 04:02 cron.4
 
Old 10-24-2004, 11:23 PM   #11
guyk
LQ Newbie
 
Registered: Mar 2004
Location: Brisbane, Australia
Distribution: Debian (Woody)
Posts: 9

Original Poster
Rep: Reputation: 0
Hi guys,

Thanks for all the suggestions. The main reason I inquired is because I didn't want the cron log full of unecessary information telling me the script had run - the script does it's own logging if there are any problems anyway. It's no big drama - I've since implemented a script to strip the lines out, just to make the cron log more readable.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job wbatzle Linux - Newbie 2 07-12-2005 04:19 PM
cron job? dr_zayus69 Linux - Newbie 14 12-01-2004 06:16 PM
cron job sanjith11 Linux - General 5 07-14-2004 01:06 PM
Cron job rajasekarvr Linux - General 4 05-03-2004 05:35 PM
Cron Job imanahmadi Linux - Newbie 1 07-03-2003 11:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:58 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