A few days ago, I blogged about changing the timezone on a Linux server. In the post, I mentioned how the zoneinfo files needed to be updated in 2007 due to congress expanding the number of days that Daylight Saving Time covers. However, I did not go in depth about how to update the zoneinfo files.

Since then, I’ve received many search queries from people looking for information about why their server did not properly update when the Daylight Saving Time change hit. For instance, I got queries of “is daylight savings default in centos”, “daylight savings time didn’t change centos”, “dst timezone change centos”, and many more. It’s clear that there are server administrators out there that are very confused about the Daylight Saving Time situation on their server.

Today, I hope to remedy that problem and give server administrators the information they need to update these zoneinfo files. I typically focus in on specific platforms, but today, I’ll try to cover as many distros as I can as well as provide a universal solution.

DST Update, Linux, and Your Server

The United States Congress signed the Daylight Saving Time change into law in 2005. In this new law, Daylight Saving Time starts on the second Sunday in March and ends on the first Sunday in November. The change took effect in the US in 2007 and will be the standard until the US Congress modifies it again.

In 2006, new zoneinfo files for Linux were released that had the new calculations necessary to account for this change in US timezone information. Most systems should have been updated automatically, but if your system doesn’t do automatic updates, the update system is malfunctioning, or the updated information wasn’t made available for your system, you’re left with a server that has its time out of sync for many days out of the year.

Checking for Old DST Calculations

A good way to find out if your zoneinfo files are updated with the new calculations is to use the time zone dumper, zdump. For example, I’ll ask my local machine running Ubuntu when the pertinent DST time changes are in 2009:

[user@server ~]$ zdump -v America/Chicago | grep 2009
America/Chicago  Sun Mar  8 07:59:59 2009 UTC = Sun Mar  8 01:59:59 2009 CST isdst=0 gmtoff=-21600
America/Chicago  Sun Mar  8 08:00:00 2009 UTC = Sun Mar  8 03:00:00 2009 CDT isdst=1 gmtoff=-18000
America/Chicago  Sun Nov  1 06:59:59 2009 UTC = Sun Nov  1 01:59:59 2009 CDT isdst=1 gmtoff=-18000
America/Chicago  Sun Nov  1 07:00:00 2009 UTC = Sun Nov  1 01:00:00 2009 CST isdst=0 gmtoff=-21600
[user@server ~]$ 

It really doesn’t matter which timezone is used since all the US timezones will report the same changes. I simply used Central since it’s my timezone.

Notice how it shows that the CST to CDT switchover point is at 2am on March 8 and how the CDT to CST switchover point is at 2am on November. This is what we want to see as it indicates that my system is using the new DST calculations and not the old ones.

So, if your system does not respond with similar output and you are checking a US timezone that includes DST calculations, you need to update your zoneinfo files.

As an odd aside, it’s interesting to note that March 8th is the earliest possible second Sunday in March and November 1st is the earliest possible first Sunday in November. We get to see this interesting arrangement again in 2015, 2020, and 2026 (more years follow of course, but I won’t bore you with them). This has no importance to the topic; I simply like patterns.

Updating zoneinfo Files the Easy Way

Fortunately, updating your zoneinfo files should not be difficult if you are using a fairly modern distro that has a package manager. The tzdata package is available on all the distro repositories that I tested and is the package we want to install/update to fix up the zoneinfo files.

Note: In order to update zoneinfo files, you must have root access. If you do not have root access, contact your hosting provider or your sysadmin and provide them with a link to this topic with a request to update the files.

For each package management system, the same steps will be followed. First, install the tzdata package. If the package manager indicates that the tzdata package is already installed, update the package. If both of these methods fail, skip down to the next section to update the files manually.

Note: You need root access to run the following commands, either access a root shell or prefix the command with ‘sudo ‘ in order to run the commands successfully.

yum

yum is the standard package manager used by most RPM-based distros, such as: CentOS, Fedora, and Red Hat Enterprise Linux (RHEL).

Install:

[root@server ~]# yum install tzdata

Update:

[root@server ~]# yum update tzdata

APT

APT is used by Debian and its derivitives, such as Ubuntu, Linux Mint, MEPIS, Damn Small Linux, and many others.

Install:

[root@server ~]# apt-get install tzdata

Update:

[root@server ~]# apt-get update tzdata

Updating zoneinfo Files Manually

If you were unable to install/update the tzdata package, were unable to find a tzdata package, or don’t have a functional package manager, you can still update your zoneinfo files. It will take a bit more work however.

The following commands will retrieve the new data, prepare it, and install it to the /usr/share/zoneinfo directory.

[user@server ~]$ wget ftp://elsie.nci.nih.gov/pub/tzdata2009b.tar.gz
[user@server ~]$ tar -xvzf tzdata2009b.tar.gz
[user@server ~]$ zic -d zoneinfo northamerica
[user@server ~]$ cd zoneinfo
[user@server zoneinfo]$ 

We now need to access a root shell. If you can use sudo, you can also just add ‘sudo ‘ to the beginning of the following command in order to temporarily gain root privileges.

[root@server zoneinfo]# cp -r * /usr/share/zoneinfo/

If you are on an old system, you may get the following error:

[root@server zoneinfo]# cp -r * /usr/share/zoneinfo/
cp: cannot create regular file `/usr/share/zoneinfo/': Is a directory
[root@server zoneinfo]# 

This means that your zoneinfo files are probably located at /usr/lib/zoneinfo. If this is the case, run the following command:

[root@server zoneinfo]# cp -r * /usr/lib/zoneinfo/

Now it’s time to test the changes.

Testing Changes

Like before, confirm that the proper dates and times are found in your zoneinfo files for the 2009 DST changes:

[user@server ~]$ zdump -v America/Chicago | grep 2009
America/Chicago  Sun Mar  8 07:59:59 2009 UTC = Sun Mar  8 01:59:59 2009 CST isdst=0 gmtoff=-21600
America/Chicago  Sun Mar  8 08:00:00 2009 UTC = Sun Mar  8 03:00:00 2009 CDT isdst=1 gmtoff=-18000
America/Chicago  Sun Nov  1 06:59:59 2009 UTC = Sun Nov  1 01:59:59 2009 CDT isdst=1 gmtoff=-18000
America/Chicago  Sun Nov  1 07:00:00 2009 UTC = Sun Nov  1 01:00:00 2009 CST isdst=0 gmtoff=-21600
[user@server ~]$ 

If you don’t receive the appropriate output, please leave me a comment with the distro you are running and what steps you have tried.

Now we just need to check that the system has the correct time. Simply run date from the command line and verify that the correct date and time are reported. If the time is still incorrect, you need to update your /etc/localtime file. You can find instructions on how to do that here.

Did I help you?