为什么我需要使用 systemd 在 RHEL7 中设置我的时区?

aaa*_*210 6 timezone systemd rhel7

我曾经能够编辑 /etc/sysconfig/clock,但现在我需要使用 timedatectl,我认为这是一个 systemd 命令。

这与启动系统有什么关系?

Mic*_*ton 4

Linux 系统上只有一个地方是有关用户态进程的系统时区的真实来源,即/etc/localtime. 事实上,timedatectl正在管理该文件,创建指向相应区域信息文件的符号链接。

[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
Run Code Online (Sandbox Code Playgroud)

编辑一/etc/sysconfig/clock开始就是一个糟糕的设计,因为它是多余的(如前所述,/etc/localtime这是系统真正使用的!),现在它已经消失了,这很好。

如果您不想使用,timedatectl您可以随时使用 puppet、ansible 等自行管理符号链接。