When sys-process/vixie-cron and sys-process/anacron are both installed, scripts under /etc/cron.daily may be executed twice a day (/etc/cron.weekly and /etc/cron.monthly likewise). (Vixie-cron under Gentoo by default calls '/usr/sbin/run-crons' every 10 minutes to decide when these scripts should be run, and record their run time in files in /var/spool/cron/lastrun). After making minor modification to /etc/anacrontab, the problem can be solved. I'll attach the patch. Reproducible: Always Steps to Reproduce: 1. emerge sys-process/anacron sys-process/vixie-cron 2. Add both anacron and vixie-cron to default runlevel 3. Actual Results: Scripts under /etc/cron.daily are executed twice a day Expected Results: They should run only once a day
Created attachment 163272 [details, diff] Patch to /etc/anacrontab
+1 5 cron.daily /usr/sbin/run-crons || run-parts /etc/cron.daily +7 10 cron.weekly test -x /usr/sbin/run-crons || run-parts /etc/cron.weekly +30 15 cron.monthly test -x /usr/sbin/run-crons || run-parts /etc/cron.monthly the cron.daily should also be a test, i presume? like so: +1 5 cron.daily test -x /usr/sbin/run-crons || run-parts /etc/cron.daily looks good otherwise...
well - this doesnt work. run-crons is provided by cronbase and anacron deps on cronbase (ie. run-crons will always be installed if you have anacron installed). we need to find a different solution...
so how about: if run-crons detects, that anacron is installed, it doesnt run any scripts?
*** Bug 79842 has been marked as a duplicate of this bug. ***
the default anacrontab in cvs has been changed to not run anything by default. a warning about the possible double execution of cron.{daily,weekly,monthly} scripts has also been added. thanks for the report.
What I'm still wandering is what the real "solution" is. From reading the cron guide: "Anacron usually relies on a cron daemon to run it each day." If I understand that correctly, then vixie-cron should only call anacron on a daily basis, but not the run-crons. Anycron again will execute the run-crons. If this is right, then the vixie-cron configuration would have to depend on whether or not anacron is installed...
I agree. Currently anacron relies on an init script to call it at startup. This doesn't seem a good idea. If I have anacron take care of cron.daily tasks, and keep my system on for two days, then those tasks are actually run only in the first day. I guess we should make cron run anacron every hour or so if it's installed, and run run-crons only if anacron is absent. (The problem with this solution is cron.hourly, but in my opinion, cron.hourly could be dropped. For tasks which need running so frequently, an usual crontab line "0 * * * * blabla" would just be fine.) (In reply to comment #7) > What I'm still wandering is what the real "solution" is. From reading the cron > guide: > > "Anacron usually relies on a cron daemon to run it each day." > > If I understand that correctly, then vixie-cron should only call anacron on a > daily basis, but not the run-crons. Anycron again will execute the run-crons. > > If this is right, then the vixie-cron configuration would have to depend on > whether or not anacron is installed... >