[Sunhelp] timezone

Dale Ghent daleg at elemental.org
Fri Aug 25 00:31:47 CDT 2000


On Fri, 25 Aug 2000, Alan Rubin wrote:

| ok, one more question related to this: does the system need to be rebooted
| after the patch is applied?  i couldn't find anything in the patch readme
| indicating that this was necessary.  when/how often does the system check
| its timezone?  is there a way to force this check from the command line?

No, a reboot is not needed for the system itself, but if you are running
daemons that are TZ-sensative (ie, those that require timezone info) will
need to be restarted.

The TZ environment variable is inherited by every process from it's parent
(that is why it's set in init... because init is ultimately the root of
all processes.) This does not change with the updated oz timezones. When a
program runs that calls the C functions that look for the TZ variable
(localtime, et all), it will read the TZ variable, and open the
appropriate timezone file (these are located in /usr/share on solaris.) 

the program does this once (when it starts) and keeps that zone info for
the duration of it's life. Here's an example with the following C program:

foo.c:

#include <sys/types.h>
#include <time.h>

int main() {

        time_t foo;
        struct tm *bar;

        while(1) {

           foo = time(NULL);
           bar = localtime(&foo);
           sleep(2);

        }
}

This program enters into an infinite loop, getting the time in seconds
since Jan 1, 1970, and then using the localtime() function to convert that
value into, well, the local time.

Doing a truss on this program shows that the timezone info file is read
once on startup, but is never read again for the duration of the process,
even though we're calling localtime() multiple times.

So, yeah, for good measure you should probably reboot your server, or at
least stop/restart any constantly running programs the require TZ
data. syslogd, web/ftp servers, and the such would be a few.

/dale






More information about the SunHELP mailing list