2006-11-25 05:53:49 TZ can not be read ??
w w (CHINA)
Message: 16880 Under the uClinux version 2006R2 and toolchain 2006R2 , the file /etc/TZ can not read by the uClinux kernel. I can "export TZ=GMT-8" to set the time zone, but when I run "echo GMT-8 > /etc/TZ" and reboot the system, the time zone is the UTC, it hasn't changed. I have selected the choice
[*] Support time zones
[*] Always load from file
and in uClibc
[*] Enable caching of the last valid timezone 'TZ' string
[*] Enable '/etc/TZ' file support to set a default timezone (uClibc-specific)
[*] Repeatedly read the '/etc/TZ' file
(/etc/TZ) Path to the 'TZ' file for setting the global timezone
What should I do ? thank you !!
QuoteReplyEditDelete
2006-11-26 21:16:33 RE: TZ can not be read ??
Mike Frysinger (UNITED STATES)
Message: 16896 try running `strace date` and see if the /etc/TZ file is actually read
the distribution no longer builds uClibc separately; it will install the uClibc that is part of the toolchain so if you need to make uClibc changes, you need to update your toolchain accordingly
QuoteReplyEditDelete
2006-11-27 05:19:50 RE: TZ can not be read ??
w w (CHINA)
Message: 16918 Thank you Mike!
I can get the right time zone with serial console, it can be read from file /etc/TZ when the system boot.
But when I telnet the system, I find that in my telnet shell, the time zone is UTC.
What's the matter ?
I can run "export TZ=GMT-8" to set the time zone, but I want to get the right value when i telnet my system and do't set anything.
Is there any suggestions ?
Thank you !!
QuoteReplyEditDelete
2006-11-28 02:26:17 RE: TZ can not be read ??
w w (CHINA)
Message: 16984 Is there no one know the question ?
I can get the right time zone from serial console, but can not get it from telnet , why ?
Thank you !!
QuoteReplyEditDelete
2006-11-28 09:45:03 RE: TZ can not be read ??
Michele d'Amico (ITALY)
Message: 16996 Hi w w,
I guess that telnetd don't spawn the TZ environment variable. If you are
interested in you could investigate/debug it by yourself.
Regards
--Michele
QuoteReplyEditDelete
2006-11-28 09:55:12 RE: TZ can not be read ??
Yi Li (CHINA)
Message: 16998 Agree.
Please do some investigation (search the web at least) by yourself
before asking questions.
QuoteReplyEditDelete
2006-11-28 14:38:13 RE: TZ can not be read ??
Robin Getz (UNITED STATES)
Message: 17012 Yi:
In our cvs ./uClinux-dist/user/telnetd/sys_term.c
void init_env(void) {
#if 0
char **envp;
envp = envinit;
if ((*envp = getenv("TZ"))!=NULL)
*envp++ -= 3;
#ifdef CRAY
else *envp++ = "TZ=GMT0";
#endif
*envp = 0;
environ = envinit;
#endif
}
In a recent version of netkit telnet/telnetd/sys_term.c from ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/netkit-telnet-0.17.tar.gz
void init_env(void) {
char **envp;
envp = envinit;
if ((*envp = getenv("TZ"))!=NULL)
*envp++ -= 3;
*envp = 0;
environ = envinit;
}
Can you check on the main uclinux-dev mailing list, why the TZ is not set properly, or if by closer inspection, our telnetd is old and out of date - can you test the new one, and update cvs?
Thanks
-Robin
QuoteReplyEditDelete
2007-10-28 17:32:33 RE: TZ can not be read ??
Øyvind Kaurstad (NORWAY)
Message: 46070 I'm bumping this old thread instead of starting a new one.
I am having a similar issue. I want to have the correct timezone, be it on the serial console or in a telnet session. If I modify the TZ file, I get what I want on the serial console, but not in a telnet session. In the serial console the TZ-variable is present, but not in the telnet console. However, several other environment variables are correctly exported in the telnet session, but I am not sure which code is responsible for that.
I'd like to have the TZ variable automatically exported in a telnet session, where is the correct place to do that? Changing #if 0 to #if 1 in init_env in sys_term.c makes no difference, since the getenv("TZ")-call returns NULL.
On the serial console:
root:~> export
export HOME
export SHELL
export TZ
export PATH
export TERM
In the telnet session:
root:~> export
export PATH
export HOME
export SHELL
export DISPLAY
export TCPLOCALPORT
export TCPREMOTEPORT
export TCPREMOTEIP
export TCPLOCALIP
export PROTO
QuoteReplyEditDelete
2007-11-01 23:51:24 RE: TZ can not be read ??
w w (CHINA)
Message: 46253
I have the same problem, but I can not resolve the question. Maybe there is something wrong about the toolchain, because I can get right result in uClinux version 2006R1.
QuoteReplyEditDelete
2009-10-21 03:56:51 RE: TZ can not be read ??
arthur chan (CHINA)
Message: 81527
whatever libc version you use, just enclose it in a C routin, it's Ok, what I do is to read the configuration file before
system();
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
5 #include <fcntl.h>
6 #include <sys/ioctl.h>
7 #include <sys/stat.h>
8 #include <string.h>
9
10 #define TZ_max_len 32
11 int main(int argc, char *argv[])
12 {
13 int fd_etc_TZ;
14 int ret;
15 char TZ_buf[TZ_max_len];
16 char *p;
17
18 p = getenv("TZ");
19 printf("this what is %s\n",p);
20
21 fd_etc_TZ = open("/etc/TZ",O_RDONLY, S_IRUSR | S_IWUSR | S_IXUSR);
22 if (fd_etc_TZ < 0) {
23 printf("open /etc/TZ err, return\n");
24 return -1;
25 }
26
27 ret = read(fd_etc_TZ, TZ_buf, TZ_max_len);
28 if (ret < 0) {
29 printf("read /etc/TZ err, return\n");
30 return -1;
31 }
32
33 p = getenv("TZ");
34 printf("this what b4 is %s\n",p);
35 system("date");
36 system("hwclock");
37
38 system("hwclock --systohc");
39 printf("after\n");
40 system("hwclock");
41
42 // putenv("TZ=CST-8");
43 setenv("TZ", (const char*) TZ_buf, 1);
44
45 p = getenv("TZ");
46 printf("this what after is %s\n",p);
47 system("date");
48
49 return 0;
50 }
51
QuoteReplyEditDelete
2011-07-25 08:38:34 RE: TZ can not be read ??
Manish Gajjaria (INDIA)
Message: 102659
Using the putenv("TZ=CST-8") command, I am able to set the Timezone value to the desired timezone.
However, while doing the date command on serial terminal / telnet the value shown is always UTC time value; and also the file /etc/TZ is not updated with the timezone information mentioned under putenv().
I have enabled the Configuration options mentioned previously.
Also, across reboots the Timezone info is always reset to UTC; how can I make the Timezone value persist across reboots?
QuoteReplyEditDelete
2011-07-25 23:21:24 RE: TZ can not be read ??
Aaron Wu (CHINA)
Message: 102660
Did you use non-volatile file system? also please do NOT reply to ancient topic, create a new one please.