Daylight Savings and UNIX? 94
Anonymous asks: "My company recently asked me to write them a report on how UNIX properly handles the switch to Daylight Savings Time, and back again. When our systems administrators received the report, I was somewhat surprised. Many of them weren't aware that 'cron' would run the affected jobs twice in the fall, and not at all in the spring. Apparently, the man pages on some operating systems, like Solaris, aren't forthcoming with details. Others groups, like database administrators, are completely unaware of the differences between epoch time and wall clock time. Are even technical users ignorant on how UNIX handles time, time zones, and time conversion?"
DST? (Score:2, Insightful)
Wrong (Score:5, Insightful)
gus
P.S. Get to it, linux guys ... maybe I will have a look.
Re:Wrong (Score:5, Informative)
Hmmm... this is what man cron gives on my Debian [debian.org] Linux box...
Re:Wrong (Score:4, Funny)
Re:Wrong (Score:4, Interesting)
I can corroborate the previous statements.
Although I am on Debian like the first two posters to reply, I did some more checking, and Debian installs vixie cron. AFAIK this is what most Linux distros install by default, including Red Hat, which I runned before this.
Would you mind telling us what distro you had to dig up to find this gem? They deserve to be rightly flamed (and by extension if you can't give a satisfactory answer, you deserve to be flamed).
MartRe:Wrong (Score:1)
Re:Wrong (Score:2)
"man 5 crontab" has the entry.
gus
Re:Wrong (Score:1)
Hmmph.
Silly SuSE.
Do you (or anyone else for that matter) know if this is fixed in later SuSE versions?
MartRe:Wrong (Score:1)
Re:=P abcd1233243459834982 (Score:1, Informative)
Re:=P abcd1233243459834982 (Score:3, Funny)
*rimshot*
--
Nope (Score:5, Insightful)
Nope, technical users know that UNIX systems should be run using GMT, which doesn't observe daylight savings time.
Re:Nope (Score:5, Insightful)
Dual boot? (Score:3, Interesting)
Linux gives you a choice about how to keep the hardware clock (Local or UTC), and the system clock is UTC with an offset setting for local time. If you're single boot with Linux, a UTC hardware clock is probably best, but if you ever want to boot into Windows, your going to have to adjust somehow.
Having the hardware clock in local time creates a problem when the time change happens, but you don't see it until you reboot. Someone incorrectly said you need to update from the hardware clock, but it is just the opposite, you have to update the hardware clock from the system clock after the time change. Since the system knows both when the change happens and whether the hardware clock is in local or UTC, it could take care of this little detail. It would be a nice touch for the distribution makers to handle this is some way. This is one of those things that doesn't really live in a single program/module but relates to interactions, so the distribution maker probably should own it. Of course, it would be nice if the hardware clock knew what the current offset is, then the issue would be easily and correctly solved.
BTW, I've always wondered about how the transition day is calculated. I've never been able to find a simple description of it. Most (all?) systems seem to know when it is, and it allways seems to be correct (for US timezones excluding Indiana), but I can't see how it could be 'calculated' from a simple rule that doesn't need to be updated from time to time. The TZ variable indicates whether the zone has DST and what the offset change is, but it doesn't have any information about when the change is. Is it just a 'last Sunday in October/April' or something like that hard coded in the library?
Re:Dual boot? (Score:3, Informative)
*snip*
Is it just a 'last Sunday in October/April' or something like that hard coded in the library?
Depends on the Country and the Hemisphere. The US (and most of North America) is first sunday in April and last sunday in Octoboer. I didn't realize that the Southern Hemisphere observers DST the other six months (ie, their summer). Seems obvious in hindsight.
Web Exhibits [webexhibits.org] has history and start/stop days by country.
I shamelessly stole a bit of DST calculation code from their web site.
Re:Dual boot? (Score:1)
Varies depending on which "cron" (Score:5, Informative)
Many Linux distributions ship with a heavily (and I mean heavily) patched up version of Vixie-cron as the default cron package. This is what many people refer to in this thread when they say "Linux cron".
There are other cron packages out there for Linux; for example, fcron [fcron.free.fr]. Section 2.2 of the fcron FAQ says:
And to further complicate matters, most commercial Unix-type OS's are either completely independent of Vixie-cron or they genetically "diverged" from Vixie-cron so long ago that they bear only faint resemblance to the original.
Maybe those technical people who you are questioning worked on a non-Linux system that doesn't suffer from the idiosyncrancies of Vixie-cron, or maybe they use fcron.
If your going to ask about your report (Score:1)
But you are right about databases. Most DBAs( that I have worked with ) are not away of the TZs effect on the database.
I guess that's what you get.... (Score:3, Funny)
Re:I guess that's what you get.... (Score:3, Funny)
Re:I guess that's what you get.... (Score:3, Informative)
Smirk. My uncle works in state government in Indiana and I tease him about this from time to time. He's been around long enough to remember the debate on this one and he says that *one* of the reasons that they don't switch is because the drive-in-movie theaters had a strong lobby the last time this was seriously discussed.
That always cracks me up. The entire state is out of step with their neighbors because of theater owners.
They are considering changing to a more conventional (notice I didn't say 'normal', just conventional) system and he says "I don't think that lobby is as strong as it used to be".
Re:I guess that's what you get.... (Score:4, Insightful)
The grand hypocracy of the whole DST gambit is the DST supporters' claim that the energy savings justify DST; i.e., let's annually sacrifice a few thousand people to save a bit of energy.
If DST supporters truly want to put an open and honest argument on the table for their position, their cost-benefit analysis needs to account for the lost lives, lost quality of life due to personal injuries, lost productivity, lost monies, etc., in addition to tallying up the energy savings and extra time spent on the golf course.
Why is it too much to expect that people turn their brains on, fire a few neurons, and produce cogent thought? DST is yet another example of, "It *feels* good so it must the right thing to do."
Re:I guess that's what you get.... (Score:2)
(Seriously though, a link or two would be cool, google didn't turn up anything interesting so I'm wondering if you got scammed. I only found a single reference to a 7% increase in 'the monday after the april change' traffic accidents, but that certainly wouldn't account for "a few thousand people" nor was the reference any kind of controlled study that would include the costs of increased pollution, kids getting hit in the dark walking to and fro school and the rest of the flavor of thing)
Why is it too much to expect that people turn their brains on, fire a few neurons, and produce cogent thought? DST is yet another example of, "It *feels* good so it must the right thing to do."
Indeed! We should ask those people to get a good nights rest before driving to work Monday morning!
Oh, I guess that's not what you meant. I suppose personal responsibility is only useful when it supports *your* argument.
Re:I guess that's what you get.... (Score:3, Informative)
Lastly, my feel good comment was in relation to the extra hours spent on the golf course. It was a bit of a flame and I probaby should have deleted that comment before posting.
Re:I guess that's what you get.... (Score:2)
I still wonder if the overall picture isn't precisely the opposite.
Re:I guess that's what you get.... (Score:2)
I personally think that everyone should switch to GMT. Why should everyone in the country wake up at 6 am local time anyway?
Joe
Re:I guess that's what you get.... (Score:1)
because it would be very confusing to have a day change 3 hours waking up? Or in the middle of lunch...
Re:I guess that's what you get.... (Score:2)
I would know that it is 19:21 Oct 10 and that my friend in California gets to work at 19:00 GMT and leaves at 3:00 GMT the next day.
Joe
Re:I guess that's what you get.... (Score:2, Informative)
Indiana Changes Time (Score:2)
Re:I guess that's what you get.... (Score:2)
Yeah, just fundamental mathematical constants [straightdope.com].
date -s (Score:1)
I can recall some really screwy things happening to make if you muck around with date -s as root. Stale files being up to date, other files being created in the future. I'd imagine Daylight Savings would be similar in some ways.
Isn't there some standard we could all agree upon, such as dates and times will be translated at submission time into GMT and cron jobs be run at whatever local time maps to the corresponding GMT? Then, if you want make local time jump around, fine, it's your own responsibility if you like discontinuous time (kind of like heavy drinking).
There's still probably room for ambiguity with all these "leap seconds" I keep hearing about...
Re:date -s (Score:3, Insightful)
System time should be set to UTC, and the time display should be seperate configuration step.
Using NTP should take care of the leap second problem, as long as your Stratum-1 server is accurate.
NTP (Score:2, Informative)
Re:NTP (Score:4, Informative)
First, NTP does not affect spring/fall time "changes" at all. Regardless of whether you have NTP or not, this "change" happens correctly. Indeed, daylight saving time only affects how time is displayed (or broken up in day, hour, minute, second), and does not affect the physical clock at all (which is kept in UTC at all times). NTP however, ensures accuracy by synching the physical clock (kept in UTC) to a master.
Moreover, the subject of this discussion is not the accuracy of the displayed time, but rather how cron (which works in local time) copes with with "duplicate" and "missing" hours. Installing NTP does nothing to help this, only picking the right cron works. Or just use the commonsense solution of not scheduling any important jobs between 2am and 3am.
Re:NTP (Score:2)
In FreeBSD... (Score:5, Interesting)
Re:In FreeBSD... (Score:3)
Time zones (Score:3, Informative)
Maybe this has been fixed by now (AFAIK as of SunOS 5.8 it hasn't) but Unix' handling of timezones has always been pretty lame. For example, if you want to change timezone in your shell (and for processes subsequently spawned) you just set the TZ environment variable. If you want to change the system time globally, su to root and use the date command, and running processes will see it next time they ask the OS for the time. OK so far. But if you want to change the timezone globally, for running processes, you can't because time zone comes from init - at the very least you have to stop and restart processes after setting TZ, and if you're going to do that, you might as well edit
Re:Time zones (Score:2, Insightful)
If your Unix box is wandering about the globe, powered, running, changing timezones willy-nilly, please do consider selecting some sort of generic time zone for the system, one that you won't feel compelled to change system-wide. Other people have mentioned GMT and UTC.
For the user, simply changing the TZ variable should mostly have the desired effect.
Re:Time zones (Score:1)
Unfortunately, it's a test rig for a date and locale sensitive application - timezone needs to be changed frequently system-wide as part of testing (the machines themselves are physically static
Daylight Savings? Blech (Score:4, Funny)
Re:Daylight Savings? Blech (Score:1)
Re:Daylight Savings? Blech (Score:1)
Re:Daylight Savings? Blech (Score:1)
Re: (Score:2)
Not having DST is Weirder (Score:2)
But it's actually weirder because the rest of the (preceived) world goes on DST.
Sporting events happen at different times, TV shows air at different times (and there is discrepancy between cable & broadcast times), and scheduled work conference calls change times.
If you think forgetting to set one or two of your clocks back is a pain, try having half of your daily schedule change times and keep straight what changes and what doesn't.
As far as the article goes, admins may not need to understand the technical details of what cron does two hours out of every year, but they sure as hell had better know if their backups and periodic maintenance is getting done!
Then again in cases I've worked missing one backup wouldn't be critical.
Grammar Nazi Time (Score:4, Informative)
It's daylight saving time, not daylight savings time. NIST [nist.gov] says so.
Anyway, if it were up to me, we wouldn't have daylight saving at all [standardtime.com].
Re:Grammar Nazi Time (Score:2, Funny)
Re:Grammar Nazi Time (Score:1)
Re:Grammar Nazi Time (Score:1)
But you were being a grammar Nazi, not a spelling Nazi, so spelling mistakes are (possibly) allowed...
Not really unaware (Score:2, Informative)
Now I am very careful about what cron jobs I run between 01:00 and 03:00 on any unix box (they might check for the existance of something at most), and accordingly leave ntpd running.
The Y2030 "Bug" (Score:2)
One thing about the whole Y2K thing--proves just how into themselves geeks are. Uber programmers were going on about a post-apocalyptic type situation, but even in developed countries where little or no Y2K fixes were made, things went just fine.
Re:The Y2030 "Bug" (Score:3, Informative)
2038 is more like it. 03:14:07 UTC on 19 January 2038, to be exact.
And no, just hoping everyone's going to be running 64-bit systems by then is not going to help if you have, for example, file formats which only allocate 4 bytes to storing a time_t value.
I'll not have reached retirement age in 2038... I wonder how many C programmers will be called out of their holes to patch programs similar to the hunt for COBOL experts at the end of last century.
Re:The Y2030 "Bug" (Score:2)
> running 64-bit systems by then is not going to
> help if you have, for example, file formats which
> only allocate 4 bytes to storing a time_t value.
If you are storing time_t in files as an int you deserve what you will get.
> I wonder how many C programmers will be called
> out of their holes to patch programs similar to
> the hunt for COBOL experts at the end of last > > century.
About one. The problem, if any, is trivial compared to the COBOL one.
Re:The Y2030 "Bug" (Score:2)
And what about those who store time_t as a time_t? On the systems I've seen, time_t is a long, which is most often 32 bits. Setting up a file format around that seems the "obvious" thing to do.
While it's true that thinking ahead makes sense, people tend not to do so if the "obvious" solution works (and will continue to work for over thirty years, by which time they hope they'll be retired).
I'd not be so sure. I can well imagine that in a bunch of places, there's just not enough space to store the extra bits, just as in the Y2K problem people had to scare up an extra two bytes in all sorts of places to store the century... which is not so good in, say, protocols which have fixed field widths. I don't think it's something trivial which can be fixed by just recompiling everything (which in itself is not trivial -- you'd really need to test the software all over again to check that you didn't break anything by compiling with wider integers).
Re:The Y2030 "Bug" (Score:1)
Most file formats that I've seen (such as OpenPGP), define the time as a 4 byte UNSIGNED value, which will work until 2106 (if I'm calculating that correctly). The odds that any file formats today will be in use by then is pretty freaking small. Anyway, I'll be 125 (long retired or long dead) at that point, so I'm not worried.
In fact there is no problem with defining time_t as an unsigned int. time()'s is defined as returning (time_t)-1 on error -- this works regardless of time_t's signedness.
OpenBSD cron (Score:1, Informative)
that has been skipped will be run immediately. Conversely, if time has
moved backward, care is taken to avoid running jobs twice.
*BSD's rock!!!
UTC (Score:3, Interesting)
anyways because of the logs and stuff, and me, being
consistent, despite living in right/Europe/Berlin zone,
switched all my clocks (server, desktop, notebook,
watch, wrist clock, microwave oven clock, car clock
etc.) to UTC. I just add the one or two hours in mind.
Re:UTC (Score:2)
Yes (Score:2)
Yes, so share your report with us, at least summerize it.
Will simply avoiding scheduled jobs between 2 and 3am solve most of our problems?
-Bill
Re:Yes (Score:2)
Will simply avoiding scheduled jobs between 2 and 3am solve most of our problems?
If your goal is to avoid the DST crossover, you should avoid 1am to 3am because it changes from 2am to 3am in the spring and from 2am to 1am in the fall.
Maybe Linux/Unix/etc. should take notes from VMS (Score:2, Interesting)
Re:Maybe Linux/Unix/etc. should take notes from VM (Score:1)
But, daylight saving time is really a jump and I wouldn't want my clock to say 8:30PM at 8:00
Windoze (Score:3, Funny)
He answered "yes" but became rather less impressed an hour later when, once again, it asked him if the clock should be reset. For fun he kept answering yes each hour till he was done with his article.
Database, cron and other timezone problems aside, at least a properly set up *nix always knows what time it is both locally and in UTC so the other programs at least have a shot at running properly.
You guys are confused... UNIX always uses GMT (1) (Score:2, Insightful)
Your time zone preference can be set on a shell-by-shell basis or process-by-process basis using the TZ environment variable. The system has a default preference that is typically
Programs can choose to use whatever timezone they wish independant of any preference. It just so happens that cron defaults to using the system local time preference but nothing prevents you from changing that if you don't like it. In fact, many cron's allow you to set the time zone you want to specify your jobs in on a user-by-user basis. So if cron's skipping around is bothering you, just switch it to GMT (1).
(note 1: well, it's either GMT or UTC, I forget which. There are subtle differences)
zoneinfo (Score:1)
man localtime
man tzset
Download the Zoneinfo source from ftp://elsie.nci.nih.gov/pub
You'll need to grab the latest versions of tzcode and tzdata. Just read the docs and source comments to learn more about time zones and daylight savings than any right thinking person would ever need/want to know.
Your company must have nothing for you to do (Score:1)
DST is backwards (Score:2)
Daylight time doesn't matter with UTC (Score:2, Informative)
Other benefits of UTC? A central logserver taking logs from hosts across the continent. "Was that at 2 Central or Eastern? Wait, what time is it in Indiana right now?" Additionally, when you have users across the world it provides a common time. I've meet many people who thought that the common Eastern timezone was still EST in the summer and never used EDT. Once again, Indiana: in the summer, it's the same as CDT, but it's still EST (unless you're near a major city on a border, in which case the appropriate [CD]DT is used). Don't add this confusion to your system accounting.
Using UTC as a common reference time for computing devices simplifies the maintenance of them and eliminates any potential problems originating from the use of local daylight time.
heheh because I'm on Pacific time, all the cron mail sent out at midnight shows up early in the evening. A side benefit.
(And NTP! Please! Accurate time is key to accurate forensics in the event of an intrusion crossing multiple boxes. Even the MacOS and XP have built-in support.)