3

When I first install a RHEL system, I select a timezone. Examining the /etc/localtime, I see that this is a copy of one of the files from /usr/share/zoneinfo.

However, when I look into changing the timezone on a system, I see a split between copying the new file and creating a symlink.

What is accepted best practice ? symlink or copy ?

Also: Does anybody have a solution for determining the timezone that the system is currently set to ? The info in /etc/sysconfig/clock is probably not correct.

2 Answers 2

3

According to this documentation it should be a symbolic link:

Name

localtime — Local timezone configuration file
Synopsis

/etc/localtime -> ../usr/share/zoneinfo/…
Description

The /etc/localtime file configures the system-wide timezone of the local system that is used by applications for presentation to the user. It should be an absolute or relative symbolic link pointing to /usr/share/zoneinfo/, followed by a timezone identifier such as "Europe/Berlin" or "Etc/UTC". The resulting link should lead to the corresponding binary tzfile(5) timezone data for the configured timezone.

Because the timezone identifier is extracted from the symlink target name of /etc/localtime, this file may not be a normal file or hardlink.

The timezone may be overridden for individual programs by using the TZ environment variable. See environ(7).

You may use timedatectl(1) to change the settings of this file from the command line during runtime. Use systemd-firstboot(1) to initialize the time zone on mounted (but not booted) system images.

In order to determine the timezone, the following command could be issued:

[vagrant@localhost ~]$ cat /etc/sysconfig/clock
ZONE="UTC"
1
  • I've also found this answer : (serverfault.com/a/631402/252509) which explicitely states that it should be a file, which is also the way redhat and ubuntu seem to set it up. Just wondering what is best practice. Nov 6, 2014 at 7:36
2

Debian maintainers explained their choice in this bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=726256

To excerpt:

Michael Biebl writes:

Changing the timezone information via timedated (org.freedesktop.timedate1 or timedatectl) will replace /etc/localtime with a symlink to the timezone file in /usr/share/zoneinfo.

That means the file will be dangling symlink during early boot and the time might be incorrectly set for systems with a separate /usr.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .