Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 235174 - sys-process/anacron: Double execution of cron scripts if regular cron is also installed
Summary: sys-process/anacron: Double execution of cron scripts if regular cron is also...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Cron Team
URL:
Whiteboard:
Keywords:
: 79842 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-19 07:10 UTC by Richard Li
Modified: 2009-11-02 10:14 UTC (History)
2 users (show)

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


Attachments
Patch to /etc/anacrontab (anacrontab.patch,698 bytes, patch)
2008-08-19 07:11 UTC, Richard Li
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Li 2008-08-19 07:10:32 UTC
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
Comment 1 Richard Li 2008-08-19 07:11:50 UTC
Created attachment 163272 [details, diff]
Patch to /etc/anacrontab
Comment 2 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2008-10-06 14:06:19 UTC
+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...
Comment 3 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2008-10-12 07:40:05 UTC
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...

Comment 4 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2008-10-13 10:49:05 UTC
so how about: if run-crons detects, that anacron is installed, it doesnt run any scripts?
Comment 5 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2008-10-13 10:51:00 UTC
*** Bug 79842 has been marked as a duplicate of this bug. ***
Comment 6 Thilo Bangert (RETIRED) (RETIRED) gentoo-dev 2009-05-12 20:24:24 UTC
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.
Comment 7 mephinet 2009-11-02 09:16:02 UTC
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...
Comment 8 Richard Li 2009-11-02 10:14:12 UTC
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...
>