Checking daylight savings settings on LinuxPosted in Linux/Unix/BSD -
The date daylight savings starts and ends changed in New Zealand last year, but unfortunately there was only a few months between when the decision was made and when it happened and the updates to the timezone databases on various Linux distributions wasn't done in time in many cases. This affected many servers and services which displayed the wrong time for the couple of weeks between when daylight savings actually started and when it would have in previous years.
Daylight savings is about to end in New Zealand this year on April 6th, whereas it would have ended this weekend on March 16th. Not wanting to have issues with my web servers like I did when daylight savings started, I decided I'd better check the setting are correct on all the servers I manage.
There is a command on Linux called "zdump" which displays the offsets for the specified timezone that are in the database. To display the timezone offset information for a specified year you would enter the following command on the command line. This can be done as an ordinary user i.e. you don't necesarily need to be root or a priviledged user to run it.
zdump -v /etc/localtime | grep 2008
The zdump command should be in your path somewhere, but if not you can easily enough find it by doing "which zdump". On a CentOS or Red Hat Enterprise Linux machine, for example, it's at /usr/sbin so you may need to enter "/usr/sbin/zdump" to run the command.
In the above example we tell zdump with the -v flag to use the timezone the server it set to (/etc/localtime) and then we run it through the grep command, telling it to only show lines with the text "2008" in them. Without the grep part of the command we'd get all the timezone setting changes from 1901 to 2038.
The output from the above command on one of my servers was this:
/etc/localtime Sat Apr 5 13:59:59 2008 UTC = Sun Apr 6 02:59:59 2008 NZDT isdst=1 gmtoff=46800 /etc/localtime Sat Apr 5 14:00:00 2008 UTC = Sun Apr 6 02:00:00 2008 NZST isdst=0 gmtoff=43200 /etc/localtime Sat Sep 27 13:59:59 2008 UTC = Sun Sep 28 01:59:59 2008 NZST isdst=0 gmtoff=43200 /etc/localtime Sat Sep 27 14:00:00 2008 UTC = Sun Sep 28 03:00:00 2008 NZDT isdst=1 gmtoff=46800
This tells me that 2:59:59 on Sunday April 6th 2008 is the equivilent of 13:59:59 on Saturday April 5th in UTC, and that the timezone is New Zealand Daylight savings Time (NZDT) and that it's daylight savings (the isdst=1 part). The next line then shows that 02:00:00 on the same day is now New Zealand Standard Time (NZST) and that daylight savings is off.
So from the above I can see that the timezone setting data is correct, and that daylight savings will tick over on the 6th of April as it should, and not any sooner.