Slashdot Mirror


Daylight Savings and UNIX?

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?"

9 of 94 comments (clear)

  1. Re:Wrong by JimR · · Score: 5, Informative

    Hmmm... this is what man cron gives on my Debian Linux box...

    Special considerations exist when the clock is changed by less than 3
    hours, for example at the beginning and end of daylight savings time.
    If the time has moved forwards, those jobs which would have run in the
    time that was skipped will be run soon after the change. Conversely,
    if the time has moved backwards by less than 3 hours, those jobs that
    fall into the repeated time will not be re-run.

    Only jobs that run at a particular time (not specified as @hourly, nor
    with '*' in the hour or minute specifier) are affected. Jobs which are
    specified with wildcards are run based on the new time immediately.

    Clock changes of more than 3 hours are considered to be corrections to
    the clock, and the new time is used immediately.
    --
    #exclude <ms/windows.h>
  2. Varies depending on which "cron" by shoppa · · Score: 5, Informative
    There are multiple cron-type systems out there.

    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. Section 2.2 of the fcron FAQ says:

    First, you must understand that fcron determines, for each job, its next time and date of execution. It then determines which of those jobs would be the next to run and then, sleeps until that job should be run. In other words, fcron doesn't wake up like Vixie cron each minute to check all job in case one should be run ... and it avoids some problems associated with clock adjusts.

    This means that if the new time value is set into the past, fcron won't run a particular job again. For instance, suppose the real time and system clock are 3:00, so the next job cannot be scheduled to run before 3:00, as it would have already been run and re-scheduled.

    First, suppose you set your system clock into the past, say to 2:00, Presuming that the last run was shortly before 3:00. then fcron will sleep until the next job should be executed. The execution time for a job is determined by identifying the last time that the job ran and computing the next scheduled time. This means that the next scheduled time must be on or after 3:01. Therefore, in this example, fcron will not run a job for at least one hour.

    Next, if you set the system time into the future, say to 4:00, fcron will run every job scheduled between the old and the new time value once, regardless of how many times it would have been scheduled. When fcron wakes up to run a job after the time value has changed, it runs all the jobs which should have run during the interval because they are scheduled to run in a past time.

    As special case is when "@xxx" style scheduling rules are involved, you must consider the "adjustment-interval". The "adjustment-interval" is the time difference between the original system time and the new system time. If the ... run at "adjust-interval" too early or too late depending of the nature of the adjust.

    To conclude, fcron behaves quite well for small clock adjusts. Each job which should have run does so once, but not exactly at the correct time as if the job were scheduled within the adjustment interval. But, if you have to make a big change in the time and date, you should probably reset all the scheduled "nextexe" by running "fcrontab -z" on all the fcrontabs.

    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.

  3. Re:I guess that's what you get.... by rw2 · · Score: 3, Informative

    confuse the cows

    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".

  4. Time zones by sql*kitten · · Score: 3, Informative

    Are even technical users ignorant on how UNIX handles time, time zones, and time conversion?

    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 /etc/default/init and reboot!

  5. Grammar Nazi Time by zsazsa · · Score: 4, Informative

    Okay, this has to be the absolutey most assinine thing I've done on Slashdot, but I've gotta do it.

    It's daylight saving time, not daylight savings time. NIST says so.

    Anyway, if it were up to me, we wouldn't have daylight saving at all.

  6. Re:The Y2030 "Bug" by pne · · 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.

    --
    Esli epei etot cumprenan, shris soa Sfaha.
  7. Re:Dual boot? by lewiscr · · Score: 3, Informative
    BTW, I've always wondered about how the transition day is calculated. I've never been able to find a simple description of it.
    *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 has history and start/stop days by country.

    I shamelessly stole a bit of DST calculation code from their web site.

  8. Re:I guess that's what you get.... by crath · · Score: 3, Informative
    A couple of links:
    Accident rates increase in response to DST---Stanley Coren of the University of British Columbia
    UK government's Transport Research Laboratory numbers---the practice of turning the clocks back had led to 3,000 deaths on Britain's roads in the last 30 years

    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.

  9. Re:NTP by BlueUnderwear · · Score: 4, Informative
    Why is this drivel moderated at 4?

    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.

    --
    Say no to software patents.