How is time zone change signalled?

Greg Larkin glarkin at FreeBSD.org
Fri Aug 7 15:37:09 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Steele wrote:
[...]
>  
> 
> The problem is with our C applications. They continue to operate with
> the old time zone, so things like timestamps in log files are not in
> sync with the timestamps in the Java app log files. If we stop and
> restart the C apps they pick up the time zone change. However, we don't
> want to take this extreme approach. We want the Java app to signal to
> the C applications that the time zone has changed. However, I've
> experimented with the various time zone related calls and I cannot
> figure out what call is needed to make the C applications pick up the
> time zone change. I've tried setting the environment variable TZ to the
> new time zone and this doesn't seem to work, and I've tried calling
> tzset() and tzsetwall(). In each case after I make these calls the
> function "localtime()" does not return the same time base as the Java
> application.
> 

Hi Peter,

Did you try unsetting TZ and then calling tzset()?  The man page implies
that doing so will force a reread of /etc/localtime
(http://www.freebsd.org/cgi/man.cgi?query=tzset&sourceid=opensearch):

"The tzset() function initializes time conversion information used by
the library routine localtime(3).  The environment variable TZ specifies
how this is done.

If TZ does not appear in the environment, the best available
approximation to local wall clock time, as specified by the
tzfile(5)-format file /etc/localtime is used."

I haven't tested it, though, and I'm no timezone expert, so I may be
completely off-base!

Cheers,
Greg
- --
Greg Larkin

http://www.FreeBSD.org/       - The Power To Serve
http://www.sourcehosting.net/ - Ready. Set. Code.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFKfEAG0sRouByUApARAkFQAKCq3PdqsoJ4aMMnNcoUgwHwOcOlLACfczQ/
vzfWIYV/n7TEgq6jIgCnVnE=
=6Bwv
-----END PGP SIGNATURE-----



More information about the freebsd-questions mailing list