Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
cron runs every minute
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
renelicious
n00b
n00b


Joined: 27 Sep 2003
Posts: 18

PostPosted: Wed Dec 03, 2003 6:47 pm    Post subject: cron runs every minute Reply with quote

I recently switched to vcron. It seem to be working great except that when I tail /var/log/messages, it seems to be running (or at least sending output to messages) every minute.

There is a line like these:

Code:


Dec  3 12:16:00 darko CRON[27520]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )
Dec  3 12:17:00 darko CRON[27810]: (root) CMD (test -x /usr/sbin/run-crons && /usr/sbin/run-crons )


as you can see about once a minute. Anyone have Any idea if this is right? If so is there at least a way to get it to stop logging this. It makes looking for any acutal useful info in the log pretty tough.

Thanks
Back to top
View user's profile Send private message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1623
Location: U.S.A.

PostPosted: Fri Dec 05, 2003 3:29 pm    Post subject: Reply with quote

You might want to post your crontab.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
dkaplowitz
Guru
Guru


Joined: 22 Nov 2003
Posts: 596
Location: Philadelphia, PA

PostPosted: Fri Jan 02, 2004 2:20 am    Post subject: Reply with quote

Decibels wrote:
You might want to post your crontab.


Code:

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
*  *  * * *     root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons


The last line is the one that's running every minute. I've never touched cron before, so I'm not sure how to disable this. I would just comment it out, but I was reading something about it not being suggested that I manually edit the file but rather use crontab -e. When I do that, however, I get a gripe about the file not existing.

Thanks in advance for any help.

Dave
_________________
http://dkap.info
Back to top
View user's profile Send private message
dkaplowitz
Guru
Guru


Joined: 22 Nov 2003
Posts: 596
Location: Philadelphia, PA

PostPosted: Sun Jan 04, 2004 10:05 pm    Post subject: Reply with quote

bump... anyone know how to disable this annoying task from running every minute and filling up my /var/log/messages?

Thanks,

Dave
_________________
http://dkap.info
Back to top
View user's profile Send private message
RAPUL
l33t
l33t


Joined: 29 Dec 2002
Posts: 664
Location: Valencia (SPAIN)

PostPosted: Sun Jan 04, 2004 10:11 pm    Post subject: Try: Reply with quote

Line with * * * * * is the one executed every minute.

Try to change that line:

Code:

test -x /usr/sbin/run-crons && /usr/sbin/run-crons


by this one:

Code:

*  *  * * *     root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons 1>/dev/null 2>/dev/null


or comment it with '#'
_________________
Entropy rulz world.
Redundancy sux.
World is full of redundancy.
World sux.
Back to top
View user's profile Send private message
dkaplowitz
Guru
Guru


Joined: 22 Nov 2003
Posts: 596
Location: Philadelphia, PA

PostPosted: Mon Jan 05, 2004 12:23 am    Post subject: Reply with quote

cool thanks. I didn't know you could edit that file manually. I commented it out.
_________________
http://dkap.info
Back to top
View user's profile Send private message
RAPUL
l33t
l33t


Joined: 29 Dec 2002
Posts: 664
Location: Valencia (SPAIN)

PostPosted: Mon Jan 05, 2004 12:28 am    Post subject: Yes tou can... Reply with quote

Yes you can edit that file to plan some activities with a frequency different than hourly, daily or weekely.

This is my crontab:

Code:

crujido big # cat /etc/crontab
*/15 * * * *    root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons
0    * * * *    root    rm -f /var/spool/cron/lastrun/cron.hourly
0    0 * * *    root    rm -f /var/spool/cron/lastrun/cron.daily
0    0 * * 6    root    rm -f /var/spool/cron/lastrun/cron.weekly
#0    0 1 * *    root    rm -f /var/spool/cron/lastrun/cron.monthly

# Frequent
00   22   *    *    *   root    /usr/bin/emerge rsync 1>/dev/null 2>/dev/null
00    2   *    *    *   root    /etc/tripwire/tripwire_check.sh 1>/dev/null 2>/dev/null
00    5   *    *    *   root    /usr/sbin/fixpackages 1>/dev/null 2>/dev/null
00    7   *    *    *   root    /usr/bin/updatedb 1>/dev/null 2>/dev/null

# Often
00   *    *    *    *   root    /usr/bin/rdate -s hora.uv.es 1>/dev/null 2>/dev/null
00   *    *    *    *   root    /bin/sh /etc/logcheck/logcheck.sh 1>/dev/null 2>/dev/null


I like to do some tasks every day at some specifics times and this one of the easiest ways of doing it...
_________________
Entropy rulz world.
Redundancy sux.
World is full of redundancy.
World sux.
Back to top
View user's profile Send private message
LRdM
n00b
n00b


Joined: 19 Jul 2003
Posts: 27

PostPosted: Sat Mar 06, 2004 8:10 pm    Post subject: Reply with quote

I have the same problem and I added 1>/dev/null 2>/dev/null to the same line and reloaded vcron but it's still showing up in my logs.

Crontab:
Code:
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
*/15 * * * *    root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons 1>/dev/null 2>/dev/null
0  *  * * *     root    rm -f /var/spool/cron/lastrun/cron.hourly
0  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


Any thoughts?
Back to top
View user's profile Send private message
glh
n00b
n00b


Joined: 07 Mar 2004
Posts: 2

PostPosted: Sun Mar 07, 2004 2:39 am    Post subject: Reply with quote

You must ensure that each cron line is truly /one/ line.

But, I would think that this redirection will not solve your problem. Usually, when a command run by cron has output, it will email it to the local user the command was run as, in this case "root".

The run-crons command that is being executed in turn executes any scripts in /etc/cron.[daily|hourly|etc] So, you don't want to comment the line out or delete it.

The syslog messages you are seeing are most likely debug messages from the cron daemon because of how it was compiled. My system does the same (vixie-cron and syslog-ng), so it seems the maintainers or developers of vixie-cron decided that this logging was a good thing.

I'm with you; I find it to be noisy. But, I think what you really want to do now, is to configure syslog-ng to your liking. By default, all syslog messages go to /var/log/messages. You can reconfigure it with /etc/syslog-ng/syslog-ng.conf. But, that file can be pretty daunting.

First, let me explain some concepts in that file. "sources" are places where messages come from. By default, there's just the one source, /dev/log, and that's just fine. Next, "destinations" are places where messages can go. By default, there's just the /var/log/messages source. Next, "logs" will actually connect sources and destinations. Lastly, and not shown in the default Gentoo install, "filters" can be used to pick certain messages from a source.

Whew! Now, onward to what we want to do. If you just want to "mute" all cron messages, you can create a new filter that matches on everything except cron. Add this line, before any "log" lines:

filter f_not_cron { not facility(cron); };

Now, this filter won't do a thing on its own. It must be put to use in a "log" line. So, change your log line with destination(messages) to:

log { source(src); filter(f_not_cron); destination(messages); };

Save the configuration file and, to get the syslog-ng process to reread the configuration, you must send the HUP signal to the process. Do this by running "ps ax | grep syslog-ng". The first column is the PID (process id) of the process shown. So, send the HUP signal by running "kill -HUP <pid>". Don't worry, that won't actually kill the process.

That should do it. Cron messages will no longer be recorded in /var/log/messages. However, cron's messages won't be recorded anywhere! So keep that in mind. A better solution might be to create a new "desination", say /var/log/cron, and a new "filter" that matches just cron, and then a new "log" line to send that filtered batch of messages to that new destination. Let me know if you want help doing all that.

Also, you might notice the other log line sending all messages to the console. This is usually at Alt-F12 from text-mode. Most folks don't even use this except when in a debugging situation, so I usually just leave it alone with all messages going to it.
Back to top
View user's profile Send private message
jokkeri
n00b
n00b


Joined: 07 Apr 2004
Posts: 1

PostPosted: Wed Apr 07, 2004 8:07 pm    Post subject: Reply with quote

glh wrote:

Whew! Now, onward to what we want to do. If you just want to "mute" all cron messages, you can create a new filter that matches on everything except cron. Add this line, before any "log" lines:

filter f_not_cron { not facility(cron); };

Now, this filter won't do a thing on its own. It must be put to use in a "log" line. So, change your log line with destination(messages) to:

log { source(src); filter(f_not_cron); destination(messages); };


How about this way:
--clip---
#destination console_all { file("/dev/console"); };
filter f_not_cron_test { not facility(cron) and not match("test"); };

log { source(src); filter(f_not_cron_test);destination(messages); };
log { source(src); filter(f_not_cron_test);destination(console_all); };

Disabling cron test messages.
Back to top
View user's profile Send private message
Tyir
Apprentice
Apprentice


Joined: 08 Mar 2004
Posts: 172
Location: Montreal

PostPosted: Fri Apr 23, 2004 11:44 pm    Post subject: Reply with quote

Hey, guys finding this post to solve the problem, do NOT COMMENT THE LINE OUT as a solution...it will cause cron to stop working!

DO what the person before me said!
Back to top
View user's profile Send private message
scwalla
n00b
n00b


Joined: 22 Mar 2004
Posts: 20

PostPosted: Thu Apr 29, 2004 10:27 pm    Post subject: Reply with quote

jokkeri wrote:
glh wrote:

Whew! Now, onward to what we want to do. If you just want to "mute" all cron messages, you can create a new filter that matches on everything except cron. Add this line, before any "log" lines:

filter f_not_cron { not facility(cron); };

Now, this filter won't do a thing on its own. It must be put to use in a "log" line. So, change your log line with destination(messages) to:

log { source(src); filter(f_not_cron); destination(messages); };


How about this way:
--clip---
#destination console_all { file("/dev/console"); };
filter f_not_cron_test { not facility(cron) and not match("test"); };

log { source(src); filter(f_not_cron_test);destination(messages); };
log { source(src); filter(f_not_cron_test);destination(console_all); };

Disabling cron test messages.


Thanks guys! I would like to point out that the logic above has a small bug. As shown above this actually filters out all log messages from cron. To filter out only the "test" lines I needed this:

Code:

filter f_not_cron_test { not facility(cron) or not match("test"); };
Back to top
View user's profile Send private message
BigBaaadBob
Guru
Guru


Joined: 19 Apr 2003
Posts: 342
Location: Swampscott, MA USA

PostPosted: Wed May 26, 2004 8:03 pm    Post subject: Reply with quote

Seems like it would be a lot easier to have a /etc/conf.d item that would tell vixie-cron not to echo every command it executes. The above does get rid of some of the annoyance, but it doesn't resolve the underlying issue.
Back to top
View user's profile Send private message
sapphirecat
Guru
Guru


Joined: 15 Jan 2003
Posts: 376

PostPosted: Wed May 26, 2004 11:03 pm    Post subject: Reply with quote

FYI: See bug 46628 for some extra commentary/info. In particular:
Jon Portnoy wrote:
I agree that every minute may be excessive. I've changed it to every ten minutes.

No revision bump because frankly I don't think it's major enough to warrant one -- remerge your cron if you want an updated /etc/crontab.

_________________
Former Gentoo user; switched to Kubuntu 7.04 when I got sick of waiting on gcc. Chance of thread necro if you reply now approaching 100%...
Back to top
View user's profile Send private message
Stratos
n00b
n00b


Joined: 23 Jan 2004
Posts: 11
Location: Denmark

PostPosted: Tue Jun 08, 2004 3:11 pm    Post subject: Reply with quote

Whether 1 or 10 minutes between run-crons, my logs still get clogged by these rather boring messages, so I did as proposed by glh, and made a special destination just for the run-crons output. I still want to catch other cron-output in the regular log, so I made a filter both on the cron facility and a match on "run-crons":

Code:

destination cron { file("/var/log/cron"); };
filter f_cron_run-crons { facility(cron) and match("run-crons"); };
log { source(src); filter(f_cron_run-crons); destination(cron); flags(final); };

The flags(final) keeps the matching messages from reappearing in the following log statements. So, by putting these statements before any other log statements, run-crons only logs to /var/log/cron.
Back to top
View user's profile Send private message
mrnegitoro
Tux's lil' helper
Tux's lil' helper


Joined: 30 Jun 2003
Posts: 77
Location: Vancouver, BC.

PostPosted: Tue Jun 08, 2004 4:38 pm    Post subject: Reply with quote

Hi,

I'm having similar problems with my cron jobs. This will probably end up being a stupid question but where exactly do I create my log filter? As shown above. I don't see a syslog.conf on my system.

Thanks.
Back to top
View user's profile Send private message
mrnegitoro
Tux's lil' helper
Tux's lil' helper


Joined: 30 Jun 2003
Posts: 77
Location: Vancouver, BC.

PostPosted: Tue Jun 08, 2004 5:02 pm    Post subject: Reply with quote

Oh, syslog-ng sorry, I'm now emerging it...
Back to top
View user's profile Send private message
mrnegitoro
Tux's lil' helper
Tux's lil' helper


Joined: 30 Jun 2003
Posts: 77
Location: Vancouver, BC.

PostPosted: Tue Jun 08, 2004 6:01 pm    Post subject: Reply with quote

Argh,

I got the logging down, it occurred to me I am using metalog (duh) but none of my freakin' cron jobs will work. I always get the same error message:

Code:
/bin/bash: line 1: root: command not found


Here is my crontab:

Code:
# $Header: /home/cvsroot/gentoo-x86/sys-apps/vcron/files/crontab,v 1.2 2002/04/27 21:46:45 bangert Exp $
#
SHELL=/bin/bash
#
# Update Locate DB at 4:00am everyday
#
00 4 * * *      root    /usr/sbin/updatedb 1>/dev/null 2>/dev/null
#
# Emerge rsync at 5am everyday
#
00 5 * * *      root    /usr/sbin/emerge rsync 1>/dev/null 2>/dev/null
#
# Pointless Testing of Crontab Crap
#
* * * * *       root    /usr/bin/test -x /usr/sbin/run-crons 1>/dev/null 2>/dev/null && /usr/sbin/run-crons 1>/dev/null 2>/dev/null
#
0 * * * *       root    rm -f /var/spool/cron/lastrun/cron.hourly
#
0 0 * * *       root    rm -f /var/spool/cron/lastrun/cron.daily
#
0 0 * * 6       root    rm -f /var/spool/cron/lastrun/cron.weekly
#
0 0 1 * *       root    rm -f /var/spool/cron/lastrun/cron.monthly


This has been going on for months, it's extremely annoying.

Thanks!
Back to top
View user's profile Send private message
sapphirecat
Guru
Guru


Joined: 15 Jan 2003
Posts: 376

PostPosted: Wed Jun 09, 2004 6:45 pm    Post subject: Reply with quote

mrnegitoro wrote:
I got the logging down, it occurred to me I am using metalog (duh) but none of my freakin' cron jobs will work. I always get the same error message:

Code:
/bin/bash: line 1: root: command not found

(Assuming you're using vixie-cron because of the "vcron" in the header of /etc/crontab.) It sounds like you ran "crontab /etc/crontab" as root by mistake. (It's only needed for other crons.) Under vixie-cron, /etc/crontab is used as the system crontab, so it needs the username in it, like yours has. But if you run 'crontab <some file>' as a user, the jobs will be run as that user who ran crontab, and the username in the file is then considered part of the command line.

(edit) To actually fix that, try moving/deleting whichever file looks like a copy of /etc/crontab in /var/spool/cron/crontabs.
_________________
Former Gentoo user; switched to Kubuntu 7.04 when I got sick of waiting on gcc. Chance of thread necro if you reply now approaching 100%...
Back to top
View user's profile Send private message
mrnegitoro
Tux's lil' helper
Tux's lil' helper


Joined: 30 Jun 2003
Posts: 77
Location: Vancouver, BC.

PostPosted: Wed Jun 09, 2004 7:04 pm    Post subject: Reply with quote

Hi,

Yeah I removed the username part "root" from crontab and all seems to be working. I did some searching last night and discovered that was the problem also. Oops some sweet redundant posting on my part but I can finally use cron jobs!

Thanks very much for your reply!
Back to top
View user's profile Send private message
gna
n00b
n00b


Joined: 19 Mar 2003
Posts: 38
Location: Beijing

PostPosted: Sat Jul 17, 2004 8:39 am    Post subject: Reply with quote

I've been getting quite annoyed by my logs being filled up with useless cron messages too. As mentioned above reducing the frequency of the run-crons definitely improves the situation but it isn't a complete solution in my view. I found the syslog-ng filtering suggestions above helpful but wasn't completely happy with the suggestions.

So I have been investigating the syslog-ng filtering and have found a solution I like (in addition to changing the crontab). I wanted to get rid of the hourly, daily messages from cron also. But I still want to see messages from cron about real errors in the messages log. I like to have one main log to look for errors rather than adding another just for cron. After a bit of fiddling I found the messages that I don't want have an "info" level priority. The following filter gets rid of cron messages with "info" or "debug" priority from the logs. Edit /etc/syslog-ng/syslog-ng.conf with the following:

Code:
# get rid of cron debug and info messages that fill up the logs
filter f_not_cron_info {not (facility(cron) and level(debug, info)); };
...
log { source(src); filter(f_not_cron_info); destination(messages); };


You can and should test the filter
Code:
logger -p cron.debug "testing cron filter"
shouldn't show up in the log but raising the priority to "notice" should get through.

There doesn't seem to be much need to change the log path that goes to the terminal so I didn't.
Back to top
View user's profile Send private message
tholin
Apprentice
Apprentice


Joined: 04 Oct 2008
Posts: 203

PostPosted: Fri Feb 25, 2011 4:47 pm    Post subject: Reply with quote

Adding special logging rules just for cron is treating the symptom instead of the problem. Anyone know if it's possible to prevent vixie-cron from sending all that junk to syslog in the first place?
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Fri Feb 25, 2011 6:23 pm    Post subject: Reply with quote

Code:
sed -i -e '/run-crons/ s|\*/10|00|' /etc/crontab

There is no reason for this line to run more than once an hour.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Fri Feb 25, 2011 6:55 pm    Post subject: Reply with quote

I've this in /etc/crontab :
Code:
*/10  *  * * *  root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons
Beside that I prefer files in /etc/cron.daily, /etc/cron.hourly etc..
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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