• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

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

by admin

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.

Filed Under: Linux

Some more articles you might also be interested in …

  1. vnstati Command Examples in Linux
  2. jpegtran: command not found
  3. eject: command not found
  4. How to Install and Configure Device Mapper Multipath in CentOS/RHEL 6,7
  5. How to check failed or bad login attempts in Linux
  6. rm Command Examples in Linux
  7. How to Delete ASM Disk on Multipath Device in CentOS/RHEL
  8. iwconfig: command not found
  9. sam: command not found
  10. chgrp: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright