Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > TZ cache on some Linux kernels

Reply
Thread Tools

TZ cache on some Linux kernels

 
 
Jon
Guest
Posts: n/a
 
      10-01-2003
While doing some time/date functions I had to change the timezone used
(by changing the ENV{TZ}) twice in one script. However, it seems the
kernel cached the last zone and failed to open or change to the new
one. I confirmed this using strace, as you could see it only opened
the one file. The code I used is as follows.

$ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';

$time = time();

($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday, $isdst) =
localtime($time);
print "$hour:$min\n";

$ENV{TZ} = ':/usr/share/zoneinfo/Europe/Paris';

($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday, $isdst) =
localtime($time);
print "$hour:$min\n";

Is the code I used. The times should be out by an hour (Paris is one
hour ahead of London), however for me they both show the same time,
which is within the London (GMT+1) timezone. The results were
different on another server.

Linux 2.4.20 complied from source, Perl 5.8.0 (RedHat RPM) - failed.
Linux 2.4.7 RedHat supplied, Perl 5.6.0 (RedHat RPM) - worked.

I should really repeat the tests with the same version of Perl on both
kernels, this time I will build Perl myself, I will try that later
today, but I wonder if anyone else can confirm this issue or maybe
point me in the direction of the problem.

Jon.
 
Reply With Quote
 
 
 
 
David Efflandt
Guest
Posts: n/a
 
      10-02-2003
On 1 Oct 2003 10:27:46 -0700, Jon <> wrote:
> While doing some time/date functions I had to change the timezone used
> (by changing the ENV{TZ}) twice in one script. However, it seems the
> kernel cached the last zone and failed to open or change to the new
> one. I confirmed this using strace, as you could see it only opened
> the one file. The code I used is as follows.
>
> $ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';
>
> $time = time();
>
> ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday, $isdst) =
> localtime($time);
> print "$hour:$min\n";
>
> $ENV{TZ} = ':/usr/share/zoneinfo/Europe/Paris';
>
> ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday, $isdst) =
> localtime($time);
> print "$hour:$min\n";
>
> Is the code I used. The times should be out by an hour (Paris is one
> hour ahead of London), however for me they both show the same time,
> which is within the London (GMT+1) timezone. The results were
> different on another server.
>
> Linux 2.4.20 complied from source, Perl 5.8.0 (RedHat RPM) - failed.
> Linux 2.4.7 RedHat supplied, Perl 5.6.0 (RedHat RPM) - worked.


man tzslect (to see what to use for TZ). Try:

$ENV{TZ} = 'Europe/London';
$time = time();
print scalar localtime($time)."\n";
$ENV{TZ} = 'Europe/Paris';
print scalar localtime($time)."\n";

--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
 
Reply With Quote
 
 
 
 
Ilya Zakharevich
Guest
Posts: n/a
 
      10-02-2003
[A complimentary Cc of this posting was sent to
Jon
<>], who wrote in article < >:
> While doing some time/date functions I had to change the timezone used
> (by changing the ENV{TZ}) twice in one script. However, it seems the
> kernel cached the last zone and failed to open or change to the new
> one. I confirmed this using strace, as you could see it only opened
> the one file. The code I used is as follows.
>
> $ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';


Check whether tzset() is required on your system... It is a Perl bug
that it does not call tzset() when/if required.

In principle, tzset() is available in POSIX.

Hope this helps,
Ilya

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fork() 50 times slower on some Linux kernels? Elmar C Programming 14 01-11-2012 10:39 PM
SCLive 3.0 With Verilog, VHDL, SystemC kernels available. dcabanis VHDL 0 10-22-2009 02:11 PM
One million [bloated?] Linux kernels booted peterwn NZ Computing 2 09-26-2009 07:55 PM
Security kernels JeZuZ Computer Security 2 09-22-2005 09:35 AM
IS there a way for windows xp to run 2 kernels at same time? Dwight Computer Support 0 07-24-2003 09:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57