1 |
On Sun, Nov 04, 2012 at 04:36:02PM +0200, Alan McKinnon wrote: |
2 |
> On Sun, 4 Nov 2012 08:58:54 -0500 |
3 |
> Michael George <george@××××××××××.com> wrote: |
4 |
> |
5 |
> > Last night was our change from EDT to EST. So we went through the |
6 |
> > 1am-2am hour twice. My crontab has the following: |
7 |
> > |
8 |
> > # for vixie cron |
9 |
> > # $Header: |
10 |
> > # /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v |
11 |
> > # 1.3 2011/09/20 15:13:51 idl0r Exp $ |
12 |
> > |
13 |
> > # Global variables |
14 |
> > SHELL=/bin/bash |
15 |
> > PATH=/sbin:/bin:/usr/sbin:/usr/bin |
16 |
> > MAILTO=root |
17 |
> > HOME=/ |
18 |
> > |
19 |
> > # check scripts in cron.hourly, cron.daily, cron.weekly and |
20 |
> > cron.monthly 59 * * * * root rm |
21 |
> > -f /var/spool/cron/lastrun/cron.hourly 9 3 * * * root rm |
22 |
> > -f /var/spool/cron/lastrun/cron.daily 19 4 * * 6 root rm |
23 |
> > -f /var/spool/cron/lastrun/cron.weekly 29 5 1 * * root rm |
24 |
> > -f /var/spool/cron/lastrun/cron.monthly */10 * * * * root test |
25 |
> > -x /usr/sbin/run-crons && /usr/sbin/run-crons |
26 |
> > |
27 |
> > So the cron.daily file should be removed at 3:09am -- it should only |
28 |
> > run once as the 2am-forward time only occurred once. |
29 |
> > |
30 |
> > However, this morning I have two sets of email from my daily jobs |
31 |
> > running. At this time: |
32 |
> > |
33 |
> > Date: Sun, 4 Nov 2012 02:20:05 -0500 (EST) |
34 |
> > |
35 |
> > and this time: |
36 |
> > |
37 |
> > Date: Sun, 4 Nov 2012 03:10:04 -0500 (EST) |
38 |
> > |
39 |
> > Why would it have run twice? |
40 |
> |
41 |
> |
42 |
> This is clearly documented in the man pages for Vixie cron. |
43 |
> |
44 |
> cron is utterly unaware of the vagaries and stupidities that humans get |
45 |
> up to recording the passage of time. If your crontab is this: |
46 |
> |
47 |
> 0 0 * * * <something> |
48 |
> |
49 |
> then when the clock says it is 0 minutes past the 0 hour, the cron will |
50 |
> run. |
51 |
> |
52 |
> That time happened twice. Therefore the cron ran twice. |
53 |
> |
54 |
> You can't really blame cron for not picking up that an event that is |
55 |
> guaranteed to happen once in a period actually happened twice in a |
56 |
> period. There comes a time when a developer has to step back and say |
57 |
> |
58 |
> "To hell with that, it's out of contract spec and actually not my |
59 |
> problem!" |
60 |
> |
61 |
> There are other crons that avoid this problem by taking a completely |
62 |
> different approach. You configure them by declaring you want a job to |
63 |
> run in a given period of time. When daylight saving kicks in, it sees a |
64 |
> job has already run and doesn't do it again. But you have to lose the |
65 |
> ability to specify the exact time a job must run at to do it this way. |
66 |
|
67 |
Actually, checking the page for cron(8) of vixie-cron, we see this: |
68 |
|
69 |
Daylight Saving Time and other time changes |
70 |
Local time changes of less than three hours, such as those |
71 |
caused by the start or end of Daylight Saving Time, are handled |
72 |
specially. This only applies to jobs that run at a specific |
73 |
time and jobs that are run with a granularity greater than one |
74 |
hour. Jobs that run more frequently are scheduled normally. |
75 |
|
76 |
If time has moved forward, those jobs that would have run in the |
77 |
interval that has been skipped will be run immediately. Conversely, |
78 |
if time has moved backward, care is taken to avoid running jobs twice. |
79 |
|
80 |
Time changes of more than 3 hours are considered to be corrections |
81 |
to the clock or timezone, and the new time is used immediately. |
82 |
|
83 |
So it seems that DST changes are accommodated. Is there some |
84 |
side-effect of the cron.<period> method of scheduling tasks that I'm |
85 |
overlooking? |
86 |
|
87 |
-- |
88 |
-M |
89 |
|
90 |
Rident stolidi verba Latina. |
91 |
-Ovid |