About this time last year, I noted that our build machines at work were way out of sync in their respective local times. As a result, we were seeing a bunch of "clock skew" warnings when building our code. To fix the problem, I figured out how to use NTP on a private network. Imagine my surprise when, while performing a build today, I noticed more clock skew warnings! I checked our setup, and NTP was still functioning as expected. The problem, it turns out, was that some of our build machines had not yet changed over to Daylight Savings Time (DST), something NTP doesn't assist with. Only the oldest machines were affected, which wasn't surprising, seeing as Congress feels the need to change the DST rules every few years.
Thankfully, updating time zone information is easy to do. Here's how:
- Step 1: Verify Your System Settings
- Clearly, we should first check to see if we even need to update our system. To do this, we can issue this command, replacing 2009 with the appropriate year:
zdump -v /etc/localtime | grep 2009
The reported DST times should correspond with your local area. In my case, the reported date on the broken systems was April 5, not March 8. So this particular system needed updating. See the end of this article for a note on potentialzdump
problems on 64-bit systems. - Step 2: Obtain the Latest Time Zone Information
- The latest time zone data can be obtained via the tz FTP distribution website. You'll want to get the
tzdata{year}{version}.tar.gz
file. In my case, the filename wastzdata2009c.tar.gz
. Copy this file to the system to be updated, and unpack it in a temporary location (I put it in a subfolder in/tmp
). - Step 3: Compile the New Time Zone Data
- We now need to compile the new time zone data. This can be done through use of the handy
zic
command:zic -d {temp_dir} {file_to_compile}
In my case, I used the name ofzoneinfo
for the{temp_dir}
parameter, and I wanted to compile thenorthamerica
file, seeing as that's where I live:zic -d zoneinfo northamerica
Upon completing this compilation step, a newzoneinfo
directory was created in the temporary location where I unpacked the time zone data. - Step 4: Copy the Newly Built Files
- Now that the appropriate files have been built, we'll need to copy the specific region files to the right location. By default, Linux time zone information lives in the
/usr/share/zoneinfo
directory. Since I live in the Eastern time zone, I copied theEST
andEST5EDT
files to the aforementioned location (I didn't know which file I really needed, so I just grabbed both). These files will overwrite the existing versions, so you may want to back those old versions up, just to be safe. In addition to this 'global time zone' file, you'll want to copy the appropriate specific time zone data file to the right place. In my case, I copied theAmerica/New_York
file to the corresponding location in the/usr/share/zoneinfo
directory. Again, you'll be overwriting an existing file, so make backups as necessary. - Step 5: Update the localtime Link in /etc
- The file
/etc/localtime
should theoretically be a soft link to the appropriate specific time zone data file in the/usr/share/zoneinfo
directory. On a few of the machines I had to update, this was not the case. To create the soft link, issue the standard command:ln -s /usr/share/zoneinfo/{path_to_zone_file} /etc/localtime
Here's the command I issued for my example:ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
- Step 6: Validate the Changes
- Now that we have installed the new time zone information file, we can verify that the data has been updated properly, again by using the zdump command:
zdump -v /etc/localtime | grep 2009
This time, the dates shown should be correct. If you issue adate
command, your time zone should also now be correct.
There is one word of warning I can provide to you. On some older 64-bit systems, the zdump
command will seg-fault when you run it. This is a bug with the installed glibc
package. I found this RedHat errata page covering the issue (at least, it refers to the package version that fixes this issue). Thankfully, I was able to compile and install the new time zone information without having to update glibc
(I simply validated my changes by issuing a date
command). It seems that only the zdump
command exhibits the seg-fault on those older systems. Your mileage may vary.