Andy J
Andy J

Reputation: 1545

TZ Variable, custom file

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!!

Upvotes: 0

Views: 3791

Answers (1)

Thomas Dickey
Thomas Dickey

Reputation: 54583

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.

Upvotes: 3

Related Questions