[comp.bugs.sys5] S5R[23] "cron" runs jobs twice when DST ends

guy@gorodish.UUCP (10/28/87)

The subject basically says it all.  The problem is that it computes the UNIX
time (GMT) when the next job is to be run by getting the UNIX time for "now",
converting it to local time using "localtime", figures out the local time for
"then", figures out how many days, hours and minutes separate the two local
time values, converts that to seconds, and adds it to the UNIX time for "now".
Needless to say, This Doesn't Work Right if DST is in effect "now" but not in
effect "then".  (Yes, I tried this on a 3B2 running 3.1; it really happens.)

The fix is to put some sort of local time to UNIX time conversion routine into
your C library - the best way to do this is to dump "ctime.c" in favor of
Arthur Olson's code, and compile it so that "timelocal" and "timegm" are
defined - and change "cron.c" so that the UNIX time for the next job is
computed by figuring out the local time for the next job and using something
such as "timelocal" to convert that to UNIX time.  (Of course, this doesn't
solve the problem of running a job at 2:10AM on the day when DST goes into or
out of effect - but *nothing* can solve *that* problem; the local time to UNIX
time mapping is neither one-to-one nor onto.)
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com