<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>8506</bug_id>
          
          <creation_ts>2002-09-28 08:42 0000</creation_ts>
          <short_desc>/usr/sbin/run-crons returns non-zero value</short_desc>
          <delta_ts>2005-03-26 15:57:37 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>1.4_rc1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P4</priority>
          <bug_severity>trivial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>captainjay@gmx.net</reporter>
          <assigned_to>cron-bugs@gentoo.org</assigned_to>
          <cc>andreas@vinsander.se</cc>
    
    <cc>ceder@lysator.liu.se</cc>
    
    <cc>gentoo@divinehawk.com</cc>
    
    <cc>h3y@esaurito.net</cc>
    
    <cc>henrik@brixandersen.dk</cc>
    
    <cc>j_r_fonseca@yahoo.co.uk</cc>
    
    <cc>lilwyrm@gmail.com</cc>
    
    <cc>tpeland@tkukoulu.fi</cc>

      

      
          <long_desc isprivate="0">
            <who>captainjay@gmx.net</who>
            <bug_when>2002-09-28 08:42:50 0000</bug_when>
            <thetext>/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

&apos;exit 0&apos; after the last line of this script may help, but probably there is a
better solution.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>captainjay@gmx.net</who>
            <bug_when>2002-09-29 16:15:06 0000</bug_when>
            <thetext>the &apos;exit 0&apos; did not help, root still got mail today..</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>woodchip@gentoo.org</who>
            <bug_when>2002-10-02 07:35:40 0000</bug_when>
            <thetext>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..
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2002-11-07 20:11:45 0000</bug_when>
            <thetext>*** Bug 10409 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>j_r_fonseca@yahoo.co.uk</who>
            <bug_when>2002-11-08 04:06:27 0000</bug_when>
            <thetext>Sorry for the duplicate. I made a quick search before submiting and saw this bug
summary but I didn&apos;t though it was the same one.

Anyway, consider the fix I suggested on #10409 .</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>j_r_fonseca@yahoo.co.uk</who>
            <bug_when>2002-11-11 11:07:48 0000</bug_when>
            <thetext>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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>woodchip@gentoo.org</who>
            <bug_when>2002-11-12 23:11:17 0000</bug_when>
            <thetext>thanks a bunch.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2002-11-13 15:31:47 0000</bug_when>
            <thetext>*** Bug 10675 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>andreas@vinsander.se</who>
            <bug_when>2004-11-02 01:25:26 0000</bug_when>
            <thetext>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&apos;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...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>henrik@brixandersen.dk</who>
            <bug_when>2004-11-02 06:44:36 0000</bug_when>
            <thetext>Reopening by request posted by Andreas Vinsander &lt;andreas.vinsander at teligent dot se&gt; to gentoo-dev@</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>henrik@brixandersen.dk</who>
            <bug_when>2004-11-02 06:45:45 0000</bug_when>
            <thetext>Re-assigning to cron-bugs.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>henrik@brixandersen.dk</who>
            <bug_when>2004-11-02 06:47:14 0000</bug_when>
            <thetext>I&apos;ve been seeing the above mentioned problem here as well.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ka0ttic@gentoo.org</who>
            <bug_when>2005-02-08 05:40:44 0000</bug_when>
            <thetext>*** Bug 81222 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ka0ttic@gentoo.org</who>
            <bug_when>2005-02-08 06:15:27 0000</bug_when>
            <thetext>Tero, btw doing find ... rm -f won&apos;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 ... &amp;&gt;/dev/null || true (like I said icky) or try (if possible) to arrange the times so they won&apos;t conflict.  That, of course, would go out the window as soon as a user modified it though.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tpeland@tkukoulu.fi</who>
            <bug_when>2005-02-08 23:24:02 0000</bug_when>
            <thetext>&gt;doing find ... rm -f won&apos;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

&quot;/bin/rm -f nonexisting&quot; would give no error message and no error value
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ka0ttic@gentoo.org</who>
            <bug_when>2005-02-09 02:38:03 0000</bug_when>
            <thetext>&gt; Not true.

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

&gt; &quot;/bin/rm -f nonexisting&quot; 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&apos;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 &quot;find /usr/portage -name &apos;*.ebuild&apos; -exec rm -f {} \;&quot; in each.  Of course, you can use something else besides the portage tree, but it&apos;s got to be something with a lot of files in order to reproduce the race condition.  I just used the tree as it&apos;s something easily recoverable.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ka0ttic@gentoo.org</who>
            <bug_when>2005-02-17 08:04:13 0000</bug_when>
            <thetext>*** Bug 82268 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>loci@locimotive.de</who>
            <bug_when>2005-03-06 09:14:10 0000</bug_when>
            <thetext>what about changing
   find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} \;
to
   find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} 2&gt; /dev/null \;

I see no place where an error report could be useful... and it&apos;s only the rm-error which is eliminated. correct me if i&apos;m wrong...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ka0ttic@gentoo.org</who>
            <bug_when>2005-03-09 04:51:25 0000</bug_when>
            <thetext>I&apos;ve added 0.3.2.  Please test and reopen if necessary.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lilwyrm@gmail.com</who>
            <bug_when>2005-03-26 15:53:53 0000</bug_when>
            <thetext>Created an attachment (id=54551)
patch to the run-crons script

I&apos;ve written a way to work around the race condition in find that&apos;s a li&apos;l less
icky than &quot;...&amp;&gt;/dev/null || true&quot;. 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&apos;ll leave it to you to add whatever changelog
entry you find appropriate.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lilwyrm@gmail.com</who>
            <bug_when>2005-03-26 15:54:05 0000</bug_when>
            <thetext>Created an attachment (id=54552)
patch to the run-crons script

I&apos;ve written a way to work around the race condition in find that&apos;s a li&apos;l less
icky than &quot;...&amp;&gt;/dev/null || true&quot;. 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&apos;ll leave it to you to add whatever changelog
entry you find appropriate.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lilwyrm@gmail.com</who>
            <bug_when>2005-03-26 15:57:37 0000</bug_when>
            <thetext>Please pardon the double-submit. &apos;Twas worlds of unintentional.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>54551</attachid>
            <date>2005-03-26 15:53 0000</date>
            <desc>patch to the run-crons script</desc>
            <filename>run-crons-0.3.3.diff</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIHJ1bi1jcm9ucy0wLjMuMgorKysgcnVuLWNyb25zLTAuMy4zCkBAIC04NCw3ICs4NCw3IEBA
CiAJCSM+PSAzMSBkYXlzLCA1IG1pbiAtPT4gKzQ0NjQ1IG1pbgogCQlUSU1FPSItY21pbiArNDQ2
NDUiIDs7CiAJZXNhYwotICAgICAgICBmaW5kICR7TE9DS0RJUn0gLW5hbWUgY3Jvbi4kQkFTRSAk
VElNRSAtZXhlYyBybSB7fSBcOyAmPi9kZXYvbnVsbCB8fCB0cnVlCisgICAgICAgIGZpbmQgJHtM
T0NLRElSfSAtbmFtZSBjcm9uLiRCQVNFICRUSU1FIC10eXBlIGYgfCB4YXJncyBybSAtZgogICAg
IGZpCiAKICAgICAjIGlmIHRoZXJlIGlzIG5vIHRvdWNoIGZpbGUsIG1ha2Ugb25lIHRoZW4gcnVu
IHRoZSBzY3JpcHRzCkBAIC0xMDQsNCArMTA0LDQgQEAKIAogIyBDbGVhbiBvdXQgYm9ndXMgY3Jv
bi4kQkFTRSBmaWxlcyB3aXRoIGZ1dHVyZSB0aW1lcwogdG91Y2ggJHtMT0NLRElSfQotZmluZCAk
e0xPQ0tESVJ9IC1uZXdlciAke0xPQ0tESVJ9IC1leGVjIC9iaW4vcm0gLWYge30gXDsgJj4vZGV2
L251bGwgfHwgdHJ1ZQorZmluZCAke0xPQ0tESVJ9IC1uZXdlciAke0xPQ0tESVJ9IC1leGVjIC9i
aW4vcm0gLWYge30gXDsK
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>54552</attachid>
            <date>2005-03-26 15:54 0000</date>
            <desc>patch to the run-crons script</desc>
            <filename>run-crons-0.3.3.diff</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIHJ1bi1jcm9ucy0wLjMuMgorKysgcnVuLWNyb25zLTAuMy4zCkBAIC04NCw3ICs4NCw3IEBA
CiAJCSM+PSAzMSBkYXlzLCA1IG1pbiAtPT4gKzQ0NjQ1IG1pbgogCQlUSU1FPSItY21pbiArNDQ2
NDUiIDs7CiAJZXNhYwotICAgICAgICBmaW5kICR7TE9DS0RJUn0gLW5hbWUgY3Jvbi4kQkFTRSAk
VElNRSAtZXhlYyBybSB7fSBcOyAmPi9kZXYvbnVsbCB8fCB0cnVlCisgICAgICAgIGZpbmQgJHtM
T0NLRElSfSAtbmFtZSBjcm9uLiRCQVNFICRUSU1FIC10eXBlIGYgfCB4YXJncyBybSAtZgogICAg
IGZpCiAKICAgICAjIGlmIHRoZXJlIGlzIG5vIHRvdWNoIGZpbGUsIG1ha2Ugb25lIHRoZW4gcnVu
IHRoZSBzY3JpcHRzCkBAIC0xMDQsNCArMTA0LDQgQEAKIAogIyBDbGVhbiBvdXQgYm9ndXMgY3Jv
bi4kQkFTRSBmaWxlcyB3aXRoIGZ1dHVyZSB0aW1lcwogdG91Y2ggJHtMT0NLRElSfQotZmluZCAk
e0xPQ0tESVJ9IC1uZXdlciAke0xPQ0tESVJ9IC1leGVjIC9iaW4vcm0gLWYge30gXDsgJj4vZGV2
L251bGwgfHwgdHJ1ZQorZmluZCAke0xPQ0tESVJ9IC1uZXdlciAke0xPQ0tESVJ9IC1leGVjIC9i
aW4vcm0gLWYge30gXDsK
</data>        

          </attachment>
    </bug>

</bugzilla>