How do I catch timezone update and perform needed actions?
cswiger at mac.com
Wed Oct 3 07:57:36 PDT 2007
Andrew McNaughton wrote:
> OK, so daylight savings just rolled over again. Applications which are
> already running apparently do not pick up the time zone change.
Nope, that doesn't just happen. See "man tzset" and maybe the misc/zoneinfo
port. And ntpd.
> In my installation apache is not regularly restarted, so it's 4 days later and
> I just noticed that apache has been putting the wrong time stamps on
> everything, and a script that regularly processes the last 10 minutes of
> log data based on time stamps on log lines has been coming up empty for
> days as a result.
> What I need is a way to stop this happening again in years to come.
If the apps are properly written, they won't care much about TZ changes
anyway. About the only sane programming practice is for applications to
always store timestamps in a format independent of TZ (ie, UTC/GMT, time_t,
etc), and always be willing to redisplay that data in the user's current
timezone (which they can change at will).
> I thought about submitting a pr asking for some system change such that
> a user configurable script gets run whenever the time zone changes.
> Perhaps such a mechanism exists already though?
> Any pointers? Should this be submitted as a pr?
You might find that setting the system TZ to GMT systemwide and then setting
the local TZ as an override in their .login or only for any users or programs
which want to know the local TZ and are smart enough to deal with DST changes.
Otherwise, the best choice is to restart everything after a timezone change.
More information about the freebsd-questions