Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
way to keep /etc/crontab quiet (no syslog entries)? [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
darylb
n00b
n00b


Joined: 13 Nov 2005
Posts: 3
Location: Ireland

PostPosted: Thu Mar 09, 2006 6:43 pm    Post subject: way to keep /etc/crontab quiet (no syslog entries)? [SOLVED] Reply with quote

Hi,
I have searched all day and found lots of information on cron and how the system wide crontabs work, and I'd like to keep this setup (as it allows running of cron jobs that were scheduled for when the system was off), but the numerous entries in /var/log/messages and on my console are doing my head in!

eg:
Code:
Mar  9 17:50:01 dblx50 cron[24552]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons)
Mar  9 18:00:01 dblx50 cron[24565]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons)
Mar  9 18:00:01 dblx50 cron[24567]: (root) CMD (rm -f /var/spool/cron/lastrun/cron.hourly)


is there anyway to stop this output being logged without commenting out the lines in /etc/crontab?

I have tried adding >/dev/null on the end, but then you get:

Code:
Mar  9 17:10:01 dblx50 cron[24418]: (root) CMD ((test -x /usr/sbin/run-crons && /usr/sbin/run-crons) >/dev/null)


so its looking like its actually cron that is producing the log? I would like to see output from this but ONLY if there was a failure, or it was my own job's output, not just to tell me that the cron checker ran every 10 minutes, so i would like to avoid having to use syslog-ng to filter this cron output to a separate log file, as then i'd miss any meaningful messages too.

cheers for any pointers!


Last edited by darylb on Fri Mar 10, 2006 4:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
sunckell
n00b
n00b


Joined: 20 Apr 2005
Posts: 19

PostPosted: Thu Mar 09, 2006 8:54 pm    Post subject: Reply with quote

Darylb,

First things first. It's probably syslog writing those files to the cron log. Depending on what you use as you logger (meta log, syslog, syslog-ng) you can edit your configuration file to not write informational messages to the log.

I would read up on your logger and check different configuration options.


-sunckell
Back to top
View user's profile Send private message
darylb
n00b
n00b


Joined: 13 Nov 2005
Posts: 3
Location: Ireland

PostPosted: Fri Mar 10, 2006 4:37 pm    Post subject: Reply with quote

Ok I got this sorted.
I imagine this annoys a lot of people so here is the answer:

in /etc/syslog-ng/syslog-ng.conf I added:
Code:
filter f_croninfo { level(info) and not facility(cron); };

and modified the log line to include:
Code:
log { source(src); filter(f_croninfo); destination(serial_console); };

this could also be added to the messages line like this:
Code:
log { source(src); filter(f_croninfo); destination(messages); };

which would probably be more relevent to a lot of people than serial console
Back to top
View user's profile Send private message
urcindalo
Guru
Guru


Joined: 08 Feb 2005
Posts: 579
Location: Almeria, Spain

PostPosted: Tue Apr 18, 2006 4:11 pm    Post subject: Reply with quote

I'm new to syslog-ng (just switched from metalog), and I find it very annoying to receive local mail everytime my /etc/crontab updates the clouds map for xplanet. The mail is sent by "Cron Daemon" to the root user. Here is my /etc/crontab:
Code:
# for vixie cron
#
# $Header: /var/cvsroot/gentoo-x86/sys-apps/vixie-cron/files/crontab-3.0.1-r4,v 1.6 2004/07/18 04:40:50 dragonheart Exp $
#
#

# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
#MAILTO=root
HOME=/

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly

#   minute (0-59),
#   |   hour (0-23),
#   |   |   day of the month (1-31),
#   |   |   |   month of the year (1-12),
#   |   |   |   |   day of the week (0-6 with 0=Sunday).
#   |   |   |   |   |   user (?) (sólo para /etc/crontab)
#   |   |   |   |   |   |   commands
#   |   |   |   |   |   |   |

0  *  * * *     root    rm -f /var/spool/cron/lastrun/cron.hourly
1  3  * * *     root    rm -f /var/spool/cron/lastrun/cron.daily
15 4  * * 6     root    rm -f /var/spool/cron/lastrun/cron.weekly
30 5  1 * *     root    rm -f /var/spool/cron/lastrun/cron.monthly
*/10  *  * * *  root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons
*  */2  *  *  *  root    cd /usr/share/xplanet/images/ && /usr/share/xplanet/images/nubes.pl
0  8  *  *  *  root  cd /usr/share/xplanet && /usr/share/xplanet/TotalMarker -norad
0  */3  *  *  *  root  cd /usr/share/xplanet && /usr/share/xplanet/TotalMarker -storm
0  23  *  *  3  root  cd /usr/share/xplanet && /usr/share/xplanet/TotalMarker -volcano
*/20  *  *  *  *  root  cd /usr/share/xplanet && /usr/share/xplanet/earthq.pl


Notice I have #MAILTO commented out, but I still get syslog-ng emails everytime the clouds map is updated (nubes.pl entry). How can I stop that? I don't want to be notified when the update is done or if the file was already up-to-date. Thanks in advance.

I find it also intriguing that only the nubes.pl entry is generating email. In fact, I thought maybe the script included the option to mail the output to root, but I see nothing in this regard:
Code:
$ cat /usr/share/xplanet/images/nubes.pl
#!/usr/bin/perl
# ------------------------------------------------------------------------------------
#  Program for downloading XPlanet cloud images from a random mirror
#
#  Copyright (c) 2003, cueSim Ltd.                  http://www.cueSim.com, Bedford, UK
#
# ------------------------------------------------------------------------------------
#
#  Redistribution and use, with or without modification, are permitted provided
#  that the following conditions are met:
#
#      * Redistributions of source code must retain the above copyright notice,
#               this list of conditions and the following disclaimer.
#      * Neither the cueSim name nor the names of its contributors may
#               be used to endorse or promote products derived from this software without
#               specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
#  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
#  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
#  SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
#  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#


use LWP::Simple;

# Set options:
#  - where to save the downloaded file (default is current directory)
my $Filename = "clouds_2048.jpg";

# - how often the image is updated on the server
my $MaxDownloadFrequencyHours = 2;

# - how many times to retry, if the server doesn't respond
my $MaxRetries = 15;

## Note: excessive requests to a single image server is discouraged.
## This script limits max retries, does not download more frequently
## than every two hours (the file is generated every 3 hours). and
## picks a random mirror location for every download.
##
## Change these settings at the risk of being blacklisted from the
## image servers.


# Get file details
if(-f $Filename)
{
        my @Stats = stat($Filename);
        my $FileAge = (time() - $Stats[9]);
        my $FileSize = $Stats[7];

        # Check if file is already up to date
        if($FileAge < 60 * 60 * $MaxDownloadFrequencyHours && $FileSize > 400000)
        {
                print "File is already up to date\n";
                exit(1);
        }
}


# Try several times to download the file if necessary
for(1..$MaxRetries)
{
        # Get a random website to hit for the file
        my $MirrorURL = GetRandomMirror("mirrors.txt");

        # Download the file
        print "Using $MirrorURL\nDownloading...\n";
        my $Response = getstore($MirrorURL, $Filename);

        # If successfully downloaded, that's it, nothing more to do
        if( IndicatesSuccess($Response))
        {
                print "Finished: file successfully downloaded to $Filename\n";
                exit(0);
        }

        # Warning that we're retrying another random server
        print "Download not available, trying another website\n\n";
}

# Warning that no servers could be contacted
print "ERROR: Tried to download the file $MaxRetries times, but no servers could provide the file\n";
exit(2);



# Return codes of 200 to 299 are "success" in HTTP-speak
sub IndicatesSuccess()
{
        my $Response = shift();
        if($Response =~ /2\d\d/)
        {
                return(1);
        }
        else
        {
                return(0);
        }
}

# Returns the name of an internet resource which can provide the clouds image
sub GetRandomMirror()
{
        # Populate a list of mirrors
        my @Mirrors = (
                       "ftp://mirror.pacific.net.au/pub2/xplanet/clouds_2048.jpg",
                       "http://spierepf.dyndns.org/~peter/clouds_2048.jpg",
                       "http://liotierj.free.fr/clouds_2048.jpg",
                       "http://www.ruwenzori.net/earth/clouds_2048.jpg",
                       "http://xplanet.dyndns.org/clouds/clouds_2048.jpg",
                       "http://userpage.fu-berlin.de/~jml/clouds_2048.jpg",
                       "http://rcswww.urz.tu-dresden.de/~es179238/clouds_2048.jpg",
                       "http://home.megapass.co.kr/~jhkim1101/cloud_data/clouds_2048.jpg",
                       "http://myhome.hanafos.com/~xplanetkorea/cloud_data/clouds_2048.jpg",
                       "http://home.megapass.co.kr/~gitto88/cloud_data/clouds_2048.jpg",
                       "http://myhome.hanafos.com/~hyoungkee/cloud_data/clouds_2048.jpg",
                       "http://giga.forfun.net/clouds_2048.jpg",
                       "http://php.nctu.edu.tw/~ijliao/clouds_2048.jpg",
                       "ftp://ftp.iastate.edu/pub/xplanet/clouds_2048.jpg",
                       "http://www.nmt.edu/~houdini/clouds_2048.jpg",
                       "http://enekyn.com/xplanet/clouds_2048.php",
                       "http://xplanet.nerp.net/clouds_2048.php");

        # Return one at random
        return $Mirrors[rand scalar(@Mirrors)];
}
Back to top
View user's profile Send private message
think4urs11
Administrator
Administrator


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Tue Apr 18, 2006 6:46 pm    Post subject: Reply with quote

urcindalo wrote:
I'm new to syslog-ng (just switched from metalog), and I find it very annoying to receive local mail everytime my /etc/crontab updates the clouds map for xplanet. The mail is sent by "Cron Daemon" to the root user.

Notice I have #MAILTO commented out, but I still get syslog-ng emails everytime the clouds map is updated (nubes.pl entry). How can I stop that? I don't want to be notified when the update is done or if the file was already up-to-date. Thanks in advance.

I find it also intriguing that only the nubes.pl entry is generating email. In fact, I thought maybe the script included the option to mail the output to root


replace
Code:
#MAILTO=root
with
Code:
MAILTO=""

Only if MAILTO is defined *and* empty no mail is send out. (man 5 crontab)

The script generates output, thats why it is mailed. If you only wan't errors mailed change the script to *only* generate output if something goes wrong.
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
urcindalo
Guru
Guru


Joined: 08 Feb 2005
Posts: 579
Location: Almeria, Spain

PostPosted: Wed Apr 19, 2006 10:46 am    Post subject: Reply with quote

Think4UrS11 wrote:
replace
Code:
#MAILTO=root
with
Code:
MAILTO=""

Only if MAILTO is defined *and* empty no mail is send out. (man 5 crontab)


Thanks very much. That did it :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum