Why do I need to use systemd to set my timezone in RHEL7?

aaa90210 asked:

I used to be able to edit /etc/sysconfig/clock, but now I need to use timedatectl, which I believe is a systemd command.

What has that got to do with booting the system?

My answer:


There is only one place on a Linux system that is the source of truth regarding the system timezone for userland processes, that is /etc/localtime. And indeed, timedatectl is managing that file, creating a symbolic link to the appropriate zoneinfo file.

[root@yaungol ~]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 23 Oct 17 00:55 /etc/localtime -> ../usr/share/zoneinfo/UTC
[root@yaungol ~]# timedatectl set-timezone Europe/London
[root@yaungol ~]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 35 Feb 12 09:27 /etc/localtime -> ../usr/share/zoneinfo/Europe/London
[root@yaungol ~]# timedatectl set-timezone UTC
[root@yaungol ~]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 25 Feb 12 09:27 /etc/localtime -> ../usr/share/zoneinfo/UTC

Editing /etc/sysconfig/clock was a bad design to begin with, since it was redundant, (as mentioned before, /etc/localtime is what the system really uses!) and it’s good that it’s gone now.

If you don’t wish to use timedatectl you can always manage the symbolic link yourself with puppet, ansible or whatever.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.