Gentoo Archives: gentoo-user

From: Michael George <george@××××××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Daylight time change and cron run twice
Date: Sun, 04 Nov 2012 20:14:36
Message-Id: 20121104201154.GA26256@brego.pewamo.office
In Reply to: Re: [gentoo-user] Daylight time change and cron run twice by Alan McKinnon
1 Well, this is what I initially thought would happen. However, my
2 crontab indicates that cron.daily would be removed at 3:09am. But at
3 2am EDT, the time changed back to 1am EST, never having reached 3:09am
4 EDT. Then after an hour it would be 2am EST, or "2am again". See here:
5 http://www.webexhibits.org/daylightsaving/b2.html
6
7 But 3:09am would never have been reached last night during EDT, only at
8 EST, so I don't expect something after 3am would ever suffer from the
9 change.
10
11 What am I missing?
12
13 On Sun, Nov 04, 2012 at 04:36:02PM +0200, Alan McKinnon wrote:
14 > On Sun, 4 Nov 2012 08:58:54 -0500
15 > Michael George <george@××××××××××.com> wrote:
16 >
17 > > Last night was our change from EDT to EST. So we went through the
18 > > 1am-2am hour twice. My crontab has the following:
19 > >
20 > > # for vixie cron
21 > > # $Header:
22 > > # /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v
23 > > # 1.3 2011/09/20 15:13:51 idl0r Exp $
24 > >
25 > > # Global variables
26 > > SHELL=/bin/bash
27 > > PATH=/sbin:/bin:/usr/sbin:/usr/bin
28 > > MAILTO=root
29 > > HOME=/
30 > >
31 > > # check scripts in cron.hourly, cron.daily, cron.weekly and
32 > > cron.monthly 59 * * * * root rm
33 > > -f /var/spool/cron/lastrun/cron.hourly 9 3 * * * root rm
34 > > -f /var/spool/cron/lastrun/cron.daily 19 4 * * 6 root rm
35 > > -f /var/spool/cron/lastrun/cron.weekly 29 5 1 * * root rm
36 > > -f /var/spool/cron/lastrun/cron.monthly */10 * * * * root test
37 > > -x /usr/sbin/run-crons && /usr/sbin/run-crons
38 > >
39 > > So the cron.daily file should be removed at 3:09am -- it should only
40 > > run once as the 2am-forward time only occurred once.
41 > >
42 > > However, this morning I have two sets of email from my daily jobs
43 > > running. At this time:
44 > >
45 > > Date: Sun, 4 Nov 2012 02:20:05 -0500 (EST)
46 > >
47 > > and this time:
48 > >
49 > > Date: Sun, 4 Nov 2012 03:10:04 -0500 (EST)
50 > >
51 > > Why would it have run twice?
52 >
53 >
54 > This is clearly documented in the man pages for Vixie cron.
55 >
56 > cron is utterly unaware of the vagaries and stupidities that humans get
57 > up to recording the passage of time. If your crontab is this:
58 >
59 > 0 0 * * * <something>
60 >
61 > then when the clock says it is 0 minutes past the 0 hour, the cron will
62 > run.
63 >
64 > That time happened twice. Therefore the cron ran twice.
65 >
66 > You can't really blame cron for not picking up that an event that is
67 > guaranteed to happen once in a period actually happened twice in a
68 > period. There comes a time when a developer has to step back and say
69 >
70 > "To hell with that, it's out of contract spec and actually not my
71 > problem!"
72 >
73 > There are other crons that avoid this problem by taking a completely
74 > different approach. You configure them by declaring you want a job to
75 > run in a given period of time. When daylight saving kicks in, it sees a
76 > job has already run and doesn't do it again. But you have to lose the
77 > ability to specify the exact time a job must run at to do it this way.
78 >
79 >
80 > --
81 > Alan McKinnon
82 > alan.mckinnon@×××××.com
83 >
84 >
85
86 --
87 -M
88
89 Rident stolidi verba Latina.
90 -Ovid