Donate

Categories

Advert

XHTML

Valid XHTML 1.0 Transitional

Time Zones and Remote Servers

It’s widely regarded that the best practice is to set the time zone of a server to UTC if people are going to be doing sys-admin work from various countries. I’m currently running some RHEL4 servers that are set to Los Angeles time. So I have to convert the time from Melbourne time to UTC and then from UTC to LA time when tracking down log entries. This isn’t really difficult for recent times (within the last few minutes) as my KDE clock applet allows me to select various time zones to display on a pop-up. For other times I can use the GNU date command to convert from other time zones to the local zone of the machine, for example the command date -d "2008-08-06 10:57 +1000" will display the current Melbourne time (which is in the +1000 time zone) converted to the local time zone. But it is still painful.

In RHEL5, CentOS 5, and apparently all versions of Fedora newer Fedora Core 4 (including Fedora Core 4 updates) the command system-config-date allows you to select Etc/GMT as the time zone to get GMT. For reference selecting London is not a good option, particularly at the moment as it’s apparently daylight savings time there.

For RHEL4 and CentOS 4 the solution is to edit /etc/sysconfig/clock and change the first line to ZONE="Etc/GMT" (the quotes are important), and then run the command ln -sf /usr/share/zoneinfo/Etc/GMT /etc/localtime. Thanks to the Red Hat support guy who found the solution to this, it took a while but it worked in the end! Hopefully this blog post will allow others to fix this without needing to call Red Hat.

In Debian the command tzconfig allows you to select 12 (none of the above) and then GMT or UTC to set the zone. This works in Etch, I’m not sure about earlier versions (tzconfig always worked but I never tried setting UTC). In Lenny the tzconfig command seems to have disappeared, now to configure the time zone you use the command dpkg-reconfigure tzdata which has an option og Etc at the end of the list.

Updated to describe how to do this in Lenny, thanks for the comments.

6 comments to Time Zones and Remote Servers

  • The way to change the timezone on Lenny or later is this: dpkg-reconfigure tzdata

    To use UTC, just select “Other” as the region.

  • andy

    `dpkg-reconfigure tzdata` is claimed to be the correct method in
    http://www.debian-administration.org/articles/213#comment_11

    its parent comment is informative, too. i’ve done it w/the /etc/localtime link in the past, but the current debian way seems to be to have the file actually present in /etc.

  • I agree this is annoying. Another way to combat this is to simply set your local timezone in your shell.

    export TZ=

  • Olivier JUDITH

    On redhat , Fedora distrib ther’s a problem whith link to /etc/locatime .
    If you rerun system-config-date and choose another timezone you can delete your original GMT file in /usr/share/zoneinfo/Etc/.
    I prefer to copy /usr/share/zoneinfo/Etc/GMT to /etc/localtime.

  • etbe

    Corey: Changing it for your shell is find for users. But for the sys-admin the most common use of dates is in system log files.

    Oliver: Is there a bugzilla for that? If not then please open one.

  • Olivier JUDITH

    it’s not a bug. but on a fresh install /etc/locatime is a file.
    Many applications like “timezone” running in shell mode copy /usr/share/zoneinfo/… contents to /etc/localtime . i also ask on fedora forum with same answer “make a link”
    from my point of view, it’s not good to make a link.

    PS: for java applications like “JMS server” support timezone change, you have to modify /etc/sysconfig/clock . for example putting ZONE=”Etc/GMT0″