ntpd sync changes the clock to a different timezone

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux
  • ntpd

Issue

  • The date and time was initially set correctly. However, when starting ntpd and syncing to the ntp servers, the time changes by 8 hours, seemingly into another timezone.

Resolution

  1. Reset the TZ to correct timezone this can be done by doing the following: export TZ=$(tzselect) and go through the process of selecting the correct timezone to get the proper code. This can be added systemwide in /etc/profile or in .bash_profile for individual users.

  2. Remove TZ set in /etc/profile so that /etc/localtime is used instead

Root Cause

TZ variable set to an invalid value resulting in NTP thinking the TZ is GMT the difficulty was that as the TZ had been set to MYT and the date command shows the timezone as MYT (which seems correct) it was hard to spot.

Diagnostic Steps

Background information

System date is changing automatically and not staying according to the Malaysia timezone which we have set on our servers.

# more /etc/sysconfig/clock
ZONE="Asia/Kuala_Lumpur"
UTC=true
ARC=false

service ntpd status
ntpd (pid  11613) is running...

Below are the contents of ntp.conf file:

# cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
server 10.x.x.x
server 10.x.x.x

System time changes automatically to incorrect timing when offset gets cleared after manually syncing with correct time and re-starting NTP service.

Mon Apr  9 14:30:25 MYT 2012 <-correct date & time

remote          refid      st t when poll reach   delay   offset  jitter
ntp server a 10.x.x.x      11 u   61   64    7    0.277  -287986   0.020
ntp server b 10.x.x.x      11 u   63   64    7    0.258  -287986   0.025

Mon Apr  9 06:30:36 MYT 2012 < date changed back 8 hours

remote            refid      st t when poll reach   delay   offset  jitter
ntp server a .STEP.          16 u  320   64    0    0.000    0.000   0.001
ntp server a .STEP.          16 u   64   64    0    0.000    0.000   0.001

Diagnostics

  1. check /etc/localtime
  2. check ntp config files
  3. check /etc/sysconfig/clock
  4. check TZ variable- set incorrectly in /etc/profile - TZ=MYT - this is a non-existent TZ should be 'Asia/Kuala_lumpur' in this case
  • Component
  • ntp

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments