Difference between revisions of "Update timezone files for earlier Daylight Savings Time"
Line 29: | Line 29: | ||
% gzip -dc tzdata*.tar.gz | tar -xf - | % gzip -dc tzdata*.tar.gz | tar -xf - | ||
− | *Step 3: Since, in our example, we are interested in the files related to the "Pacific" timezone, we will only need "<code>northamerica</code>" and/or "<code>pacificnew</code>". (note: Some modifications where made to the <code>europe</code> and <code>africa</code> files as well, and the last command, <code>zic backwards</code>, will complain if you | + | *Step 3: Since, in our example, we are interested in the files related to the "Pacific" timezone, we will only need "<code>northamerica</code>" and/or "<code>pacificnew</code>". (note: Some modifications where made to the <code>europe</code> and <code>africa</code> files as well, and the last command, <code>zic backwards</code>, will complain if you do not include them.) Here are the commands to run (as root): |
% cd /path/to/tzdata2007c | % cd /path/to/tzdata2007c | ||
Line 55: | Line 55: | ||
Remember to make this file executable, like so: | Remember to make this file executable, like so: | ||
% chmod 775 /etc/cron.hourly/time-sync | % chmod 775 /etc/cron.hourly/time-sync | ||
+ | |||
+ | ==timedatectl== | ||
+ | ''Note: Most of these commands will need to be run as either root or sudo.'' | ||
+ | |||
+ | * List all available timezones on your computer/server: | ||
+ | $ timedatectl list-timezones | ||
+ | |||
+ | * Set your computer's/server's timezone: | ||
+ | $ timedatectl set-timezone region/timezone | ||
+ | |||
+ | * For instance, to set your timezone to United States Pacific Time (PST; -8GMT): | ||
+ | $ timedatectl set-timezone America/Vancouver | ||
+ | |||
+ | Your system will be updated to use the selected timezone. You can verify with: | ||
+ | $ timedatectl | ||
==References== | ==References== |
Revision as of 11:32, 13 November 2014
Because of the Energy Policy Act of 2005, beginning in 2007, the United States will begin observing Daylight saving time (DST) from the second Sunday in March until the first Sunday in November.[1]
Older Linux kernels are using the older definition of DST and the files that control this will need to be updated. Below I will show you how to do this.
- Step 1: Check that you are using the older DST definition.
To determine if your time zone has an issue, run this command (note that zdump
might be located under /sbin/zdump
or /usr/sbin/zdump
):
% zdump -v /etc/localtime | grep 2007
For an example, if you are living in the "Pacific" time zone, you should get something like the following:
/etc/localtime Sun Apr 1 09:59:59 2007 UTC = Sun Apr 1 01:59:59 2007 PST isdst=0 gmtoff=-28800 /etc/localtime Sun Apr 1 10:00:00 2007 UTC = Sun Apr 1 03:00:00 2007 PDT isdst=1 gmtoff=-25200 /etc/localtime Sun Oct 28 08:59:59 2007 UTC = Sun Oct 28 01:59:59 2007 PDT isdst=1 gmtoff=-25200 /etc/localtime Sun Oct 28 09:00:00 2007 UTC = Sun Oct 28 01:00:00 2007 PST isdst=0 gmtoff=-28800
Notice that those dates do not correspond to the second Sunday in March nor the first Sunday in November. If you see this in the output, then your DST will not start (or end) on the correct day.
The time zone files are usually found here:
/usr/share/zoneinfo/
and they are usually linked to the /etc/localtime
% ls -lah /etc/localtime lrw-r--r-- 1 root root 1.1K Jan 5 2006 /etc/localtime -> /usr/share/zoneinfo/America/Vancouver
- Step 2: Download the patch from here. You will need the file
tzdata2007c.tar.gz
(this may have changed since writing this). Then execute the following commands under the appropriate directory (they are usually located under/usr/share/zoneinfo
):
% wget 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz' % gzip -dc tzcode*.tar.gz | tar -xf - % gzip -dc tzdata*.tar.gz | tar -xf -
- Step 3: Since, in our example, we are interested in the files related to the "Pacific" timezone, we will only need "
northamerica
" and/or "pacificnew
". (note: Some modifications where made to theeurope
andafrica
files as well, and the last command,zic backwards
, will complain if you do not include them.) Here are the commands to run (as root):
% cd /path/to/tzdata2007c % zic europe % zic africa % zic northamerica % zic backwards
Et voilà! Now, check your results with the original command again:
zdump -v /etc/localtime | grep 2007
and you should see something like this:
/etc/localtime Sun Mar 11 09:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 PST isdst=0 gmtoff=-28800 /etc/localtime Sun Mar 11 10:00:00 2007 UTC = Sun Mar 11 03:00:00 2007 PDT isdst=1 gmtoff=-25200 /etc/localtime Sun Nov 4 08:59:59 2007 UTC = Sun Nov 4 01:59:59 2007 PDT isdst=1 gmtoff=-25200 /etc/localtime Sun Nov 4 09:00:00 2007 UTC = Sun Nov 4 01:00:00 2007 PST isdst=0 gmtoff=-28800
It's the "Mar 11" and "Nov 4" that tell us we have successfully updated our /etc/localtime
file.
Sync localtime with rdate
Example: Create a file, e.g. /etc/cron.hourly/time-sync
, with the following lines:
#!/bin/bash /usr/bin/rdate -s time1.u.washington.edu
Remember to make this file executable, like so:
% chmod 775 /etc/cron.hourly/time-sync
timedatectl
Note: Most of these commands will need to be run as either root or sudo.
- List all available timezones on your computer/server:
$ timedatectl list-timezones
- Set your computer's/server's timezone:
$ timedatectl set-timezone region/timezone
- For instance, to set your timezone to United States Pacific Time (PST; -8GMT):
$ timedatectl set-timezone America/Vancouver
Your system will be updated to use the selected timezone. You can verify with:
$ timedatectl