Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 8506 - /usr/sbin/run-crons returns non-zero value
Summary: /usr/sbin/run-crons returns non-zero value
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Low trivial (vote)
Assignee: Cron Team
URL:
Whiteboard:
Keywords:
: 10409 10675 81222 82268 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-09-28 08:42 UTC by Johannes Krause
Modified: 2010-03-27 22:40 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to the run-crons script (run-crons-0.3.3.diff,585 bytes, patch)
2005-03-26 15:53 UTC, Drake Wyrm
Details | Diff
patch to the run-crons script (run-crons-0.3.3.diff,585 bytes, patch)
2005-03-26 15:54 UTC, Drake Wyrm
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Krause 2002-09-28 08:42:50 UTC
/usr/sbin/run-crons from sys-apps/cronbase returns a non-zero value, so root
gets mail from Cron Daemon containing the following line every day:

find: /var/spool/cron/lastrun/cron.hourly: No such file or directory

'exit 0' after the last line of this script may help, but probably there is a
better solution.
Comment 1 Johannes Krause 2002-09-29 16:15:06 UTC
the 'exit 0' did not help, root still got mail today..
Comment 2 Donny Davies (RETIRED) gentoo-dev 2002-10-02 07:35:40 UTC
are you still having this and do you know if this is a bonified bug, and/or 
have a fix/further suggestion?

i have to admit i dont use the run-crons and cronbase extra stuff since
i fine fcron much easier for my needs ;-)

lemme know..
Comment 3 SpanKY gentoo-dev 2002-11-07 20:11:45 UTC
*** Bug 10409 has been marked as a duplicate of this bug. ***
Comment 4 José Fonseca 2002-11-08 04:06:27 UTC
Sorry for the duplicate. I made a quick search before submiting and saw this bug
summary but I didn't though it was the same one.

Anyway, consider the fix I suggested on #10409 .
Comment 5 José Fonseca 2002-11-11 11:07:48 UTC
The solution I suggested on bug #10409, of replacing

    find /var/spool/cron/lastrun/cron.$BASE $TIME -exec rm {} \;

by

    find /var/spool/cron/lastrun/ -name cron.$BASE $TIME -exec rm {} \;

effectively solves this problem.

Please apply it on portage.
Comment 6 Donny Davies (RETIRED) gentoo-dev 2002-11-12 23:11:17 UTC
thanks a bunch.
Comment 7 SpanKY gentoo-dev 2002-11-13 15:31:47 UTC
*** Bug 10675 has been marked as a duplicate of this bug. ***
Comment 8 Andreas Vinsander 2004-11-02 01:25:26 UTC
I want to revive this one...
We are sometimes seeing the same behaviour on some of our systems running sys-apps/vixie-cron-3.0.1-r4 and sys-apps/cronbase-0.3.1. 

The problem seems to be that on each hour the file cron.hourly is removed by /etc/crontab. If it doesn't exist or if it is older than 65 minutes, then /usr/sbin/run-crons will activate hourly jobs (/usr/sbin/run-crons is started once each 10 minutes by /etc/crontab).

There is a race condition here. If run-crons finds a cron-hourly file, but it is removed before run-crons finds out if it is more than 65 minutes old, then the message regarding /var/spool/cron/lastrun/cron.hourly will be mailed out.
A completely harmless bug... but can be annoying if it happens a lot.

Sorry for not giving a solution... hope somebody can use the diagnose though...
Comment 9 Henrik Brix Andersen 2004-11-02 06:44:36 UTC
Reopening by request posted by Andreas Vinsander <andreas.vinsander at teligent dot se> to gentoo-dev@
Comment 10 Henrik Brix Andersen 2004-11-02 06:45:45 UTC
Re-assigning to cron-bugs.
Comment 11 Henrik Brix Andersen 2004-11-02 06:47:14 UTC
I've been seeing the above mentioned problem here as well.
Comment 12 Aaron Walker (RETIRED) gentoo-dev 2005-02-08 05:40:44 UTC
*** Bug 81222 has been marked as a duplicate of this bug. ***
Comment 13 Aaron Walker (RETIRED) gentoo-dev 2005-02-08 06:15:27 UTC
Tero, btw doing find ... rm -f won't work, as find still returns an error value as well as displaying the No such file or directory message.  We can either do something icky like find ... &>/dev/null || true (like I said icky) or try (if possible) to arrange the times so they won't conflict.  That, of course, would go out the window as soon as a user modified it though.
Comment 14 Tero Pelander 2005-02-08 23:24:02 UTC
>doing find ... rm -f won't work, as find still returns an error value as well as displaying the No such file or directory message.

Not true.

Only cases that show error value are:
rm without -f
find with nonexisting base directory

"/bin/rm -f nonexisting" would give no error message and no error value
Comment 15 Aaron Walker (RETIRED) gentoo-dev 2005-02-09 02:38:03 UTC
> Not true.

> Only cases that show error value are:
> rm without -f
> find with nonexisting base directory

> "/bin/rm -f nonexisting" would give no error message and no error value

Yes, however, with the race condition, it exists when find starts but not when it gets to the part where it tries to rm -f it.  That's a find error, not a rm error.

If you really want to test it, open two terminals next to each other and as simultaneously as possible, run "find /usr/portage -name '*.ebuild' -exec rm -f {} \;" in each.  Of course, you can use something else besides the portage tree, but it's got to be something with a lot of files in order to reproduce the race condition.  I just used the tree as it's something easily recoverable.
Comment 16 Aaron Walker (RETIRED) gentoo-dev 2005-02-17 08:04:13 UTC
*** Bug 82268 has been marked as a duplicate of this bug. ***
Comment 17 Christian B. 2005-03-06 09:14:10 UTC
what about changing
   find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} \;
to
   find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} 2> /dev/null \;

I see no place where an error report could be useful... and it's only the rm-error which is eliminated. correct me if i'm wrong...
Comment 18 Aaron Walker (RETIRED) gentoo-dev 2005-03-09 04:51:25 UTC
I've added 0.3.2.  Please test and reopen if necessary.
Comment 19 Drake Wyrm 2005-03-26 15:53:53 UTC
Created attachment 54551 [details, diff]
patch to the run-crons script

I've written a way to work around the race condition in find that's a li'l less
icky than "...&>/dev/null || true". I tested it out with your suggestion of
removing the portage tree, and it works swimmingly with no extraneous output.

	(simultaneously, from two consoles)
$ find portage/ -type f | xargs -l rm -f
$ echo $?
0

Submitted for your approval, and I'll leave it to you to add whatever changelog
entry you find appropriate.
Comment 20 Drake Wyrm 2005-03-26 15:54:05 UTC
Created attachment 54552 [details, diff]
patch to the run-crons script

I've written a way to work around the race condition in find that's a li'l less
icky than "...&>/dev/null || true". I tested it out with your suggestion of
removing the portage tree, and it works swimmingly with no extraneous output.

	(simultaneously, from two consoles)
$ find portage/ -type f | xargs -l rm -f
$ echo $?
0

Submitted for your approval, and I'll leave it to you to add whatever changelog
entry you find appropriate.
Comment 21 Drake Wyrm 2005-03-26 15:57:37 UTC
Please pardon the double-submit. 'Twas worlds of unintentional.