Linux Timezone – Fix `timedatectl set-timezone` Not Updating `/etc/timezone`

arch linuxdatelinuxtimezone

I expected that timedatectl would update /etc/timezone when changing timezones, but no:

% sudo timedatectl set-timezone 'Asia/Kuala_Lumpur'
% cat /etc/timezone
Asia/Bangkok

Is there a reason that it doesn't? (Bug?)

If I manually update /etc/timezone to match timedatectl set-timezone, are there any side-effects I should be aware of?

Is there anywhere else I should consider changing timezone, eg xfce4 panel clock?

Best Answer

timedatectl updates /etc/localtime, which is the documented way of setting the default timezone in most Linux-based environments (along with its override, the TZ environment variable, which is the only POSIX-defined way of specifying the timezone).

/etc/timezone appears to be mostly Debian-specific (including derivatives). On Debian systems, timedatectl set-timezone also updates /etc/timezone.

If you manually update /etc/timezone, you should also update the /etc/localtime symlink (and make sure you keep the latter a symlink). Updates to /etc/localtime appear to be taken into account by (most?) desktop environments, so there’s no need to use environment-specific tools to update the timezone.

If you’re running Debian, you should use dpkg-reconfigure tzdata to configure the default timezone; that updates /etc/localtime and /etc/timezone as above, and it also updates the selected timezone in the debconf database (which serves as the default when configuring tzdata). If you don’t do this, the next time tzdata is updated, the timezone will be restored to the value in the debconf database. dpkg-reconfigure tzdata also takes care of updating the SE Linux context, if you’re using SE Linux.

Related Question