Updating Linux tzdata for DST changes

So, you are a sysadmin living/managing servers in Egypt or in Egypt’s timezone. Or even a good faithful linux user. The government, in it’s infinite wisdom, decided that we should go back to DST. Are you sure you are ready for this?

index

Since I do run servers a lot of servers in the Africa/Cairo timezone, mostly Ubuntu LTS and Debian servers, I looked to see if there is an update for the tzdata package in Ubuntu that would include this, but couldn’t find any (bug report ?).

Although it’s not the best way to do this, I decided to create the timezone datafile myself. IANA is responsible for providing the datafiles. I downloaded the datafiles package, untared it, and checked the the africa file I was happy to see this:

Rule Egypt 2014 only - May 15 24:00 1:00 S

So, the file is up to date. No, using instructions from this awesome debian wiki page, I did the following to compile and test the datafile:

# cd /tmp/
# mkdir tzdata
# cd tzdata
# wget http://www.iana.org/time-zones/repository/releases/tzdata2014c.tar.gz
# tar zxvf tzdata2014c.tar.gz
# zic -d . africa
# TZ="/tmp/tzdata/Africa/Cairo" date --date="2014-05-15 01:00:00 UTC"
    Thu May 15 03:00:00 EET 2014
# TZ="/tmp/tzdata/Africa/Cairo" date --date="2014-05-16 01:00:00 UTC"
    Fri May 16 04:00:00 EEST 2014

As you can see, the time representation will change according the the timezone file. Now, all you need to do, is to copy it in place:

# cp /tmp/tzdata/Africa/Cairo /usr/share/zoneinfo/posix/Egypt
# cp /tmp/tzdata/Africa/Cairo /etc/localtime

Remember that you might need to do something similar if you have any Java applications, Java timezone files are provided by the package tzdata-java.

Now, to apply this on all of our servers, we used Ansible. A simple playbook should do the trick:

---
- hosts: all
  sudo: yes
  tasks:
    - name: Update timezone file
      copy: src=/path/to/data/file dest={{ item }}
      with_items:
        - /usr/share/zoneinfo/posix/Egypt
        - /etc/localtime
      when: ansible_os_family == "Debian"

This should be it! However, this is not meant to be a permanent solution. You should update your tzdata package as soon as the next update is released.

UPDATE: I just found out that the Ubuntu had released a critical update to fix this problem. You don’t need to perform these steps now, just make sure to get the latest tzdata package. Not sure about debian, yet.