I am administering a CentOS 6 Linux OS.
I want to remove all explicit timezone information where such information may cause anything but UTC timezone for the system. This is because it is a template of a virtual machine, and also because it has been decided to have the default timezone as UTC.
Do I have to change the
/etc/sysconfig/clock file (I assume this is CentOS specific configuration entity), or
/etc/localtime, or both? Can I remove both, and will it then fall back to UTC or some other intrinsic defaults? I just cannot find documentation on how the system behaves without these files, for instance. Or maybe I should not be removing either, but then why is there a timezone preference distributed over two files? Unless it has slightly different meaning in each?
I can test empirically of course, but I may change the distro in the future, and then will have another timezone again, while my scripts try to shoot for distro-neutral compatibility.
The default timezone is no timezone, that is, UTC time. There is no hardcoded zone information as it could very quickly become incorrect/obsolete.
The kernel clock always runs on UTC (or at least what it thinks is UTC). By default, it expects to read UTC time from the hardware clock (RTC), but allows the boot process to specify the correct “local time” offset, as most PCs keep local time in the RTC.
Userspace works with UTC-based “epoch” timestamps, but reads
/etc/localtime or the
$TZ environment variable when displaying the dates. If neither exists, you’ll get UTC.
You can also explicitly set them to “UTC” or “Etc/UTC” if you want (e.g.
export TZ=UTC to temporarily override the system-wide zone).
Some distributions split the configuration since zoneinfo files themselves don’t have the zone name inside, so once the admin copied
/etc/localtime, it is no longer possible to know that it was “Europe/London”.
For example, the name is needed when showing the current zone in setup screens, or when updating the
localtime file on every boot (it needs to be copied to /etc again every time zoneinfo is updated).
Other distributions solve this by symlinking the zoneinfo file instead, and reading the symlink’s target. This however needs
/usr to be mounted very early, which is disliked by graybeards.
The configuration files are not portable;
/etc/sysconfig is specific to Red Hat (Debian has
/etc/default). However, on systemd systems the symlink approach is always used, and there is a
timedatectl set-timezone tool for changing it.
In my line of work, machines move physically around the world from time to time, so association with a timezone would just cause problems.
What I do, as I’m a big fan of UTC too, is set the timezone to Reykjavik. This results in UTC +0, without that pesky DST.
What you do to change this when needed, is to symlink
/etc/localtime to whatever suitable timezone definition in
/usr/share/zoneinfo/. I’m not sure if this is CentOS-specific either, we just happen to use a lot of CentOS servers.