How to Disable Daylight Savings Time (DST), and Modify the Timezone on Linux

Many countries do not follow DST changes, and by default, they are configured so DST time changes alter their system times and even the database times running on them. This post outlines steps to disable DST and modify the timezone on a Linux server.

In this example, the time is set as per Brazil country, with a timezone of GST-3.

OS files involved:

/etc/sysconfig/clock
/etc/localtime

If you look in the directory /usr/share/zoneinfo/Etc on the server, you will see subdirectories by country and even by timezone within the country. You need to identify what directory and subfiles for your target host.

In our example we are on the East coast in Brazil, GST-3:00. There are zoneinfo files which have the difference from DST hard coded:

GMT
GMT0
GMT-0
GMT+0
GMT-1
GMT+1
GMT-2
GMT+2
GMT-3
GMT+3
GMT-4
GMT+4
GMT-5
GMT+5
GMT-6
GMT+6
GMT-7
GMT+7
GMT-8
GMT+8
GMT-9
GMT+9
GMT-10
GMT+10
GMT-11
GMT+11
GMT-12
GMT+12
GMT-13
GMT-14

So, the directory/file for them would be: /usr/share/zoneinfo/Etc/GMT-3

1. Modify the file /etc/sysconfig/clock to read:

# vi /etc/sysconfig/clock
ZONE="Etc/GMT-3"
UTC=true
ARC=false

2. Follow these steps to correctly set the file/link /etc/localtime:

# cd /etc
# rm /etc/localtime
# ln -s /usr/share/zoneinfo/Etc/GMT-3 /etc/localtime
# ls -al localtime
# date

The ‘ls -la localtime’ command above should show the file /etc/localtime as a symbolic link to /usr/share/zoneinfo/Etc/GMT-3. Also ‘date’ command should return the correct time for Brazil East- GST-3:00.

3. For databases- the only thing you have to make sure of is that the DB OS owner does not have any environmental variables of “TZ” set. When your databases start- if they do not see any TZ variables set- they will use the OS time as the DB time.

– Connect as DB user and run:

# env |grep -i TZ

The output of the above command should show nothing set at the OS as “TZ=”. If there is some timezone already set, then you need to modify the Oracle Db user’s profile so this is unset.

Related Post