[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: time zone on linux



Hi Mark

Thanks for the reply.

But if the timezone changes while daemon is running, simply calling localtime 
and asctime will not help.  Because localtime doesn't look at /etc/localtime 
from second time onwards unless we set TZ environment variable again to the 
new value. For that my daemon needs to know  that  time zone has changed.

I can do that in one way. I can continuously monitor the access time of 
/etc/localtime file and update my TZ variable when it is modified. Or I can 
look at access time only when I need to call localtime. 

I want to know if there is any other simpler solution. Please tell me if u 
know. Even syslogd also tracks the changes in time zone. Do u know how it 
does it.  I obserevd that the access time of /etc/localtime is getting 
modified continuously. That means some body is continuously reading it.

Thanks

Bye
Satish


On Tue, Nov 20, 2001 at 06:57:11PM +0530, kilaru wrote:
> Now my doubt is how will I know if root changes timezone while my daemon is 
> running?( I do not want to kill and restart the daemon).
> 
> If any body knows how to do it please tell me.

If your Linux box was setup properly, the system time will actually be
in GMT, and it will just convert for display based upon /etc/localtime.
You shouldn't have to update the timezone manually in that case (at
least, all of my Debian boxen automatically change between PDT and PST
just fine).  What you should do in your daemon is use localtime()
internally (number of seconds since 1970 in GMT), and then use asctime()
or mktime() on display only to translate into the local timezone.

If the hardware clock is not set to GMT, you're working with a broken
setup, and should fix that first.

M




Reply to: