Admin Books

DOWNLOAD Free e-Books for Linux Admin Servers :

Fix the timezone data on CentOS Into Correctly Local Time Zone


I've had an annoying issue on some CentOS 5 virtual machines where I set the timezone to Pacific/Auckland and it doesn't work. This post shows the error and then how to rebuild/reinstall the timezone data.
Changing the timezone

I wanted to change the timezone from Eastern time to New Zealand time. To highlight how it didn't work the example below shows: the date command, showing the current date, time and timezone; attempting to set the date; and then showing the current date and time again.
1 $ date
2 Wed May 16 23:23:23 EDT 2012
3 $ ln -sf /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
4 $ date
5 Wed May 16 23:26:23 EDT 2012

No, it didn't seem to make any difference. The timezone is still EDT.
The fix

It's very easy, simply run "yum reinstall tzdata -y" as root or using sudo. The -y flag at the end simply means you don't need to type y and <enter> when it's time to say yes, you do want to do the reinstall.
1 $ yum reinstall tzdata -y
2 ... lots of output ...
3 $ ln -sf /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
4 $ date
5 Thu May 17 15:30:42 NZST 2012

Excellent, now the timezone has changed.

References:

Related posts:

  • Change the timezone on CentOS (Wednesday, September 14th 2011)
  • Set the timezone on Debian 5 Lenny (Thursday, December 30th 2010)
  • Checking daylight savings settings on Linux (Thursday, March 13th 2008)

No comments:

Post a Comment