LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-13-2006, 08:57 AM   #1
cruiserfriend
LQ Newbie
 
Registered: Jan 2006
Distribution: ELDK
Posts: 3

Rep: Reputation: 0
Question TimeZone change doesn't effect current process


Hi Cracks,

as I am new to this forum, let me say HELLO and please allow me to post here and not as a newbie

I am changing the time zone, changing the link /etc/localtime to something different e.g. /usr/share/zoneinfo/Europe/Berlin.
Everything is fine, date now shows correct time regarding to the time zone, but any already running process is not effected. I wrote a simple test app, which does nothing than calling time(0) and printf the time. When relaunching the process, it also shows the correct time.
Any idea to let the time zone change effect running processes.

Thanks for any reply
cruiserfriend
 
Old 01-14-2006, 04:54 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,943
Blog Entries: 5

Rep: Reputation: 753Reputation: 753Reputation: 753Reputation: 753Reputation: 753Reputation: 753Reputation: 753
All time in Linux/Unix is "epoch" which is the number of seconds since Jan 1, 1970. All time zones are relative to Universal (UTC also known as GMT or Zulu).

Setting your time zone only change how you see the time not the actual time.

For example if I have processes showing STIME of 16:50 in my EST5EDT zone then do "export TZ=PST8PDT" and then do ps -ef for them they now show 13:50 for STIME.

Setting your TZ variable is different from setting the default time zone of your system. TZ only affects what you see now.
 
Old 01-14-2006, 05:35 PM   #3
RedShirt
Senior Member
 
Registered: Oct 2005
Location: Denver
Distribution: Sabayon 3.5Loop2
Posts: 1,150

Rep: Reputation: 45
Also note that most of the time you change your time, the system clock in KDE/gnome may update, may not depending on distro. The same goes for many clock utilities, software programs and other things. In many cases you need to restart the system for timezone, display preferences, etc.
 
Old 01-15-2006, 03:36 AM   #4
cruiserfriend
LQ Newbie
 
Registered: Jan 2006
Distribution: ELDK
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlightner
Setting your time zone only change how you see the time not the actual time.
For example if I have processes showing STIME of 16:50 in my EST5EDT zone then do "export TZ=PST8PDT" and then do ps -ef for them they now show 13:50 for STIME.
To make it more clearly. I am developping the front end user interface for an embedded system based on ELDK (Embedded Linux development kit).
From within this application I want to change the time zone and the next programmatic calls to time and localtime should consider the new time zone (The time is shown on a display and can already be changed and is synchronized with NTP).
That is "how I see the time, not the actual time".
If I restart the application, time and localtime correctly consider the new time zone.
Guess there are some tables initialized when starting a process. Is there any way to reinitialize the tables?
There is also no environment variable TZ set. How should this effect the calls to time and localtime within an application?

Thanks again for any hints!

cruiserfriend
 
Old 01-17-2006, 03:27 AM   #5
cruiserfriend
LQ Newbie
 
Registered: Jan 2006
Distribution: ELDK
Posts: 3

Original Poster
Rep: Reputation: 0
Time zone

I found the solution myself, so this thread can be closed.

The current process (which should change the time zone itself or should know about time zone change by monitoring /etc/localtime) should set the environment variable TZ - e.g. setenv("TZ, "Europe/Berlin", 1) - and then initialize time conversion information with tzset(), so the time zone change takes effect to the next localtime call. That's it.

cruiserfriend
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change timezone using date davholla Linux - General 16 11-09-2005 02:53 AM
How to get the current process information balasquare@yahoo.com Programming 4 09-29-2005 04:39 AM
New process w/o current parent? novaprime Programming 2 01-04-2005 09:06 PM
How to configure TimeZone to change automatic .. piraxter Slackware 1 04-09-2003 11:14 PM
How does moving partition effect the booting process? concoran Linux - General 9 10-20-2001 02:58 AM


All times are GMT -5. The time now is 03:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration