Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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:
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...
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)
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.
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.
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.