Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] Daylight time change and cron run twice Michael George <george@××××××××××.com>
Re: [gentoo-user] Daylight time change and cron run twice Michael George <george@××××××××××.com>