Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 621706 - Cron scripts in /etc/cron.{daily,weekly,monthly} are run twice by run-crons from sys-process/cronbase-0.3.7-r6 and anacron from sys-process/cronie-1.5.0-r1.
Summary: Cron scripts in /etc/cron.{daily,weekly,monthly} are run twice by run-crons f...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Cron Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-14 04:36 UTC by anonymous
Modified: 2018-02-14 10:21 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description anonymous 2017-06-14 04:36:50 UTC
I noticed this because 'zpool scrub' was run once per day for two days in a row.
It was meant to be run once per month.

It seems run-cruns from sys-process/cronbase-0.3.7-r6 and anacron from sys-process/cronie-1.5.0-r1 run the scripts in /etc/cron.{daily,weekly,monthly} independently of each other.
Comment 1 anonymous 2017-06-14 04:49:40 UTC
run-crons manages /var/spool/cron/lastrun.
anacron manages /var/spool/anacron

/sudo:root@gentoo:/var/spool/cron/lastrun:
  total 20K
  -rw-r--r-- 1 root root 0 Jun 14 07:50 cron.daily
  -rw-r--r-- 1 root root 0 Jun 14 13:00 cron.hourly
  -rw-r--r-- 1 root root 0 May 21 17:10 cron.monthly
  -rw-r--r-- 1 root root 0 Jun  8 18:20 cron.weekly

/sudo:root@gentoo:/var/spool/anacron:
  total 19K
  -rw------- 1 root root 9 Jun 14 08:33 cron.daily
  -rw------- 1 root root 9 May 20 10:57 cron.monthly
  -rw------- 1 root root 9 Jun 10 08:23 cron.weekly
Comment 2 anonymous 2017-06-14 04:53:35 UTC
Let me explain the flow of execution.

/etc/crontab from cronie makes crond execute run-crons from cronbase.

run-crons runs scripts in /etc/cron.{hourly,daily,weekly,monthly} on regular intervals.

/etc/cron.hourly/0anacron from cronie runs scripts in /etc/cron.{daily,weekly,monthly} on regular intervals.
Comment 3 anonymous 2017-06-15 07:17:32 UTC
I can circumvent this issue by disabling 'anacron' use flag in cronie.

cronie's anacron conflicts with cronbase.
Comment 4 nic 2017-12-04 04:34:20 UTC
see man crond for cronie
"Nowadays the file </etc/crontab> is empty by default.  Originally it was usually used to run daily, weekly, monthly jobs.  By default these jobs are now run through anacron which reads /etc/anacrontab configuration file."


/etc/crontab should NOT contain these lines if USE=anacron.
Comment or delete, it is safe to remove the file if everything is in /etc/anacrontab

 # check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
 59  *  * * *    root    rm -f /var/spool/cron/lastrun/cron.hourly
 9  3  * * *     root    rm -f /var/spool/cron/lastrun/cron.daily
 19 4  * * 6     root    rm -f /var/spool/cron/lastrun/cron.weekly
 29 5  1 * *     root    rm -f /var/spool/cron/lastrun/cron.monthly
 */10  *  * * *  root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons




upstream has a contrib file 0hourly to be placed in /etc/cron.d/
https://github.com/cronie-crond/cronie/blob/master/contrib/0hourly

 # Run the hourly jobs
 SHELL=/bin/bash
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 MAILTO=root
 01 * * * * root run-parts /etc/cron.hourly



alternatively I've seen others insert that line into /etc/crontab, you do not need both.

 01 * * * * root run-parts /etc/cron.hourly
Comment 5 nic 2017-12-04 04:46:01 UTC
duplicate? bug 551352
Comment 6 anonymous 2017-12-04 11:23:59 UTC
I think https://bugs.gentoo.org/show_bug.cgi?id=551352 is a different issue from this. I didn't need to deal with file permissions that was talked about in 551352.

Since cronbase comes with gentoo base and this issue occurs after cronie is installed, I think it makes sense to modify relevant gentoo packages so that people fumble around until they find this issue.

In other linux distros including ArchLinux, cronie didn't have this issue.
Comment 7 anonymous 2017-12-04 11:24:54 UTC
I found an error.

"so that people fumble around until they find this issue." -> "so that people won't fumble around until they find this issue."
Comment 8 anonymous 2017-12-04 11:33:42 UTC
Does it make sense to install a different version of /etc/crontab if anacron USE flag is enabled in cronie?
Comment 9 nic 2017-12-06 18:33:06 UTC
I may have misread bug 551352, comment 5 for it referenced a similar tweak with the 0hourly cron file - I agree the symptoms reported are different

Yes, a separate /etc/crontab when anacron is enabled makes sense to me.
Comment 10 Alexander Tsoy 2018-02-05 01:33:09 UTC
(In reply to epinephrine from comment #9)
> I may have misread bug 551352, comment 5 for it referenced a similar tweak
> with the 0hourly cron file - I agree the symptoms reported are different

Bug 551352 was filed agains older version of crontab before commit [1]. Before that commit cronie with USE=anacron didn't run cron scripts at all. After that commit it run cron script twice.

[1] https://gitweb.gentoo.org/repo/gentoo.git/commit/sys-process/cronie/files/cronie-1.3-crontab?id=c474dda61c900197ef05e64d1e5af35785cbb7c1
Comment 11 Alexander Tsoy 2018-02-05 03:49:10 UTC
It is also interesting that run-crons script from sys-process/cronbase is duplicating anacron's functionality (just read the script) :)
Comment 12 Larry the Git Cow gentoo-dev 2018-02-14 10:21:15 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f79f8ac5d95fa3f88301f0bad8b03e9d5f497a59

commit f79f8ac5d95fa3f88301f0bad8b03e9d5f497a59
Author:     Alexander Tsoy <alexander@tsoy.me>
AuthorDate: 2018-02-05 03:23:05 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2018-02-14 10:21:09 +0000

    sys-process/cronie: fix USE=anacron mess
    
    run-crons script from sys-process/cronbase is duplicating anacron's
    functionality. And since we run run-crons every 10 minutes and anacron
    every hour, we end up running every daily/weekly/monthly cron job twice.
    Fix this by removing run-crons from crontab.
    
    Also enable USE=anacron by default because this is closer to behaviour we
    previously had with USE=-anacron (thanks to run-crons).
    
    Closes: https://bugs.gentoo.org/621706
    Closes: https://github.com/gentoo/gentoo/pull/7079

 sys-process/cronie/cronie-1.5.1-r1.ebuild | 101 ++++++++++++++++++++++++++++++
 sys-process/cronie/files/cronie-crontab   |  17 +++++
 2 files changed, 118 insertions(+)