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.
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
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.
I can circumvent this issue by disabling 'anacron' use flag in cronie. cronie's anacron conflicts with cronbase.
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
duplicate? bug 551352
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.
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."
Does it make sense to install a different version of /etc/crontab if anacron USE flag is enabled in cronie?
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.
(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
It is also interesting that run-crons script from sys-process/cronbase is duplicating anacron's functionality (just read the script) :)
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(+)