Postgres Timezone unchanged after trying to match with the Linux Operating System.

Document ID : KB000011386
Last Modified Date : 14/02/2018
Show Technical Document Details
Question:

After running the following commands to match the Postgres and Operating System's time zones and to fix possible aggregation problems, the Postgres time zone value stays the same in the LINUX system.  Why is the time zone unchanged?

 

The commands used are:

1) Remove the old TZ: $rm /etc/localtime

2) Link new TZ:           $ln -sf /usr/share/zoneinfo/Brazil/East /etc/localtime

3) Restart Postgres:     /etc/rc.d/init.d/postgresql-8.4 restart

Environment:
All supported APM releases with a Linux OS.
Answer:

Linux systems uses the GLIBC dynamic time zones, based on /etc/localtime. This file is a link or copy of a zone information file, usually located under the /usr/share/zoneinfo directory.

From a geophysical perspective, there is only (360/15) or 24 Time Zones in the world. But to make things easier to configure, and to accommodate all the political variations (like Daylight Savings Time), you will find hundreds of zone info files in /usr/share/zoneinfo. These are for every world city, country, etc.

Some countries, like Brazil, do not have a fixed day to start Daylight Savings Time. It is defined every year, a couple of months before summer. For this reason timezone acronyms can change from state by state as follow:

 

NAME and SHIFT        DST Name and Shift       Locations

BREST -2:00              BREDT -1:00                   Fernando de Noronha

BRST -3:00                BRDT -2:00                     Sao Paulo, Brasilia, Minas Gerais, Northeast Region, South Region

BRWST -4:00             BRWDT -3:00                  West Region

BRAST -5:00              BRADT -4:00                   Acre

 

In some cases, Postgres does not recognize the DST time zone such as "BRDT." For this reason, the above commands do not work when changing the Postgres time zone.

 

When facing this kind of mismatch, set the specific time zone directly in PostgresSql.Conf file:

 

BEFORE

#log_timezone = unknown

#timezone = unknown

 

AFTER

log_timezone = America\Sao_Paulo

timezone = America\Sao_Paulo