1

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?

  • 1
    I don't think many things use /etc/timezone, localtime() and co. don't. if $TZ is not set, what matters is /etc/localtime – Stéphane Chazelas Jun 25 '18 at 9:41
4

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.

  • 1
    And to answer Tom's other question, timedatectl is a systemd thing that queries timedated over dbus and timedated derives the name of the timezone (like Europe/London) by doing a readlink() on /etc/localtime. If /etc/localtime is not a symlink, then that name cannot be derived as those timezone definition files don't contain that information. – Stéphane Chazelas Jun 25 '18 at 9:55
  • I use dpkg-reconfigure tzdata on Debian to configure the system timezone. I assume it does what is needed. It does modify /etc/timezone and /etc/localtime – Stéphane Chazelas Jun 25 '18 at 10:05
  • Thanks @Stéphane, good point about dpkg-reconfigure, running that is necessary to ensure the setting is preserved across package upgrades. – Stephen Kitt Jun 25 '18 at 10:10
  • On Debian systems, timedatectl set-timezone also updates /etc/timezone - Hmm, not so on Manjaro (Arch-based). I've let them know. – Tom Hale Jun 26 '18 at 6:16
  • Thanks @StéphaneChazelas, you may be interested in this answer based on your comment. – Tom Hale Jun 26 '18 at 6:45
-2

/etc/timezone is fully optional on UNIX. It is not used by any official system software.

The timezone you have in mind is typically inherited from init(1) via login to the shell.

From the documentation, /etc/timezone is intended to contain time zone names in relation to host or domainnames.

  • What's an official system software? What do you mean by UNIX? What documentation are you referring to? – Stéphane Chazelas Jun 25 '18 at 9:57
  • Software delivered with the system. Typical UNIX systems are Solaris, AIX, HP-UX. FreeBSD. – schily Jun 25 '18 at 9:59
  • 3
    Do any of those systems have a timedatectl command? – Stéphane Chazelas Jun 25 '18 at 10:06
  • No, but the documented content of /etc/timezone is something like US/Eastern East.Sun.COM #Sun East Coast. Is this what timedatectlsets up? – schily Jun 25 '18 at 11:45
  • You seem to be referring to the /etc/timezone file used by the sysidtool software on Solaris to build NIS maps. It is specific to Solaris. timedatectl is a systemd utility to interact with its timedated service, which suggests the OP is running a GNU/Linux system using systemd's init framework, more specifically, probably a Debian-based one as that /etc/timezone file is mostly Debian-specific. See also 0pointer.de/public/systemd-man/timezone.html, out-of-date as systemd no longer uses that file even on Debian. – Stéphane Chazelas Jun 25 '18 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.