0

I have an embedded system where we wish to create custom daylight savings times.

I can achieve this by setting the TZ environment variable, for example: export TZ=IST-2IDT,M3.4.4/26,M10.5.0.

We have several daemons running (eg. daemonA, daemonB, etc.), and if one of those exports TZ then the other daemons won't be able to see it. So that's an issue. A possible work around might be to use a file instead of an environment variable so that 'everyone' can see it.

The GNU C Library manual says the following:

:characters Each operating system interprets this format differently; in the GNU C Library, characters is the name of a file which describes the time zone.

When I export TZ=:/etc/TZ, and then echo IST-2IDT,M3.4.4/26,M10.5.0 > /etc/TZ, it doesn't work. I see this, when I issue the date command:

Mon Aug 15 04:19:36 /etc/TZ 2016

Is anybody able to give me any clues?

Thanks so much!!

Andy J
  • 1,479
  • 6
  • 23
  • 40

1 Answers1

3

Files such as /etc/TZ depend on the type of system (call them nonstandard as such, though standardization is poor in this area). The usual way timezone is configured is via the /etc/localtime files. Normally these are generated from rule (text) files by the timezone compiler. It is in the tzfile manual page for instance.

The timezone-in-date is a good place to start reading further - since it mentions a few possibilities regarding /etc/TZ. If /etc/TZ is what works for your system, the accepted answer there points to this Oracle page, which appears to document the format.

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • Hi Thomas. I'm using glibc. I've done a little research and it seems glibc/eglibc don't use /etc/TZ, but instead use /etc/localtime just like you said. The /etc/localtime way works, but does not suit my requirements because I need to be able to create custom timezones at runtime, when using the embedded board. The TZ environment variable achieves this but other daemons cannot see it (as mentioned in the original post). – Andy J Feb 16 '15 at 04:30
  • 2
    Whether you set an environment variable or update /etc/localtime, you would have to restart the other daemons to make them use the new timezone settings. – Thomas Dickey Feb 16 '15 at 09:19
  • 1
    You may have seen this, of course: http://lists.busybox.net/pipermail/buildroot/2012-October/060338.html – Thomas Dickey Feb 16 '15 at 11:35