Updating time zone information on a Linux machine

This post was written by eli on September 2, 2013
Posted Under: Linux

Since daylight saving time is an issue for political dispute in Israel, the time of switching back and forth changes all too often. To keep my computer on track, I need to update the timezone info file every now and then.

There are a lot of tutorials on the web about this, for example these two. Here’s a quick summary:

Check the current situation. Is the timezone file in sync with the real world?

$ zdump -v /etc/localtime | less

Ah, so it isn’t. Go to IANA’s site and download the data file (e.g. tzdata2013d.tar.gz). From within that bundle, fetch the file named “asia”. And go:

$ zic -d tmpdir asia

which creates a new directory, tmpdir, with several zone files inside.

Unfortunately, trying to run zdump on just a file doesn’t work very well. So I went to /usr/share/zoneinfo and removed the file called Israel as well as Asia/Jerusalem and Asia/Tel_Aviv, and the /etc/localtime as well. They were all the same, identical file.

Then copied tmpdir/Asia/Jerusalem into /usr/share/zoneinfo/Asia and

# ln -s /usr/share/zoneinfo/Asia/Jerusalem localtime

Plus, in /usr/share/zoneinfo/Asia, just to be safe:

# ln -s Jerusalem Tel_Aviv

and in /usr/share/zoneinfo:

# ln -s Asia/Jerusalem Israel

And a final check (same as before)

$ zdump -v /etc/localtime | less

A machine reboot may be in place to make all programs catch up with the new data. Or just restart key programs, if it doesn’t matter all that much.

Just to be 100% sure that the change is in effect, a one-liner script can be used. For example how is GMT time vs. local time compare 48 days from now?

$ perl -e '$t=time() + 86400*48; print scalar gmtime($t)." --> ".scalar localtime($t)."\n";'

Side notes: The sources for zic and other utilities are available next to the data file on IANA’s site. But any sane Linux distribution should have these installed already. Or at least at the repository. Also worth to note, that the syntax of these data files is pretty cool: It’s not just dates, but political rules.

 

Reader Comments

תודה רבה!
עזר לי מאד. בצעתי את ההנחיות וההתנהגות של המכונה נכונה.

גמח”ט,
דוד פולק, קב’ סעד

#1 
Written By דוד פולק on September 12th, 2013 @ 16:45

There’s Moshe in the National Library in Jerusalem keeps one eye on the Knesset, one ear on IBA Kol Yisrael radio news open 24/7 and his hand on the clock dial. But only for .ac.il and the big carfrier subscribers.
timeserver.iix.net.il (192.114.62.250) http://www.isoc.org.il/iix/2x_ntp.html
http://www.tau.ac.il/israel-faq/q10.html

? > il.pool.ntp.org
companies market ntp clocks,
e.g. http://ntp.co.il/?cat=23
but where is the ntp for the rest of us?

Yesterday 27 Oct 5:00 AM my MS-windows 8.0 dropped an hour back to 4:00 for my local Jerusalem time, The Window’s adjust internet time menu is limited. The MS time.windows.com, one of 5 ntp options, is not current with Israel’s variable political daylight savings.

Your code looks like handy for local linux users.

#2 
Written By Yohanan Weininger on October 28th, 2013 @ 07:28

Hi My teach Blog!
i have read your page that’s good for me.
but i have one problem about cofiguration NTP not success.
ex: [thongveasna@ftp02 ~]$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
10.79.65.150 .INIT. 16 u – 1024 0 0.000 0.000 0.000
[thongveasna@ftp02 ~]$
[thongveasna@ftp02 ~]$
[thongveasna@ftp02 ~]$ date
Fri Mar 11 13:31:22 ICT 2016
—–
Real time 1:46 PM

#3 
Written By david jame on March 11th, 2016 @ 08:46

I can’t see last line, is that “perl” or “pearl”?

Thanks!

#4 
Written By John Kirren on December 3rd, 2016 @ 16:39

Dear Eli.
Thanks for the detailed guide.
It was very helping for me.
Gmh”t!

#5 
Written By Ofer on September 29th, 2022 @ 12:02

Add a Comment

required, use real name
required, will not be published
optional, your blog address