当我第一次安装RHEL系统时,我选择了一个时区.检查/ etc / localtime,我看到这是/usr/share / zoneinfo中的一个文件的副本.
但是,当我考虑更改系统上的时区时,我发现在复制新文件和创建符号链接之间存在分歧.
什么是最佳实践?符号链接还是复制?
另外:是否有人有解决方案来确定系统当前设置的时区? / etc / sysconfig / clock中的信息可能不正确.
解决方法
根据
this documentation,它应该是一个象征性的链接:
- Name
- localtime — Local timezone configuration file
- Synopsis
- /etc/localtime -> ../usr/share/zoneinfo/…
- Description
- The /etc/localtime file configures the system-wide timezone of the local system that is used by applications for presentation to the user. It should be an absolute or relative symbolic link pointing to /usr/share/zoneinfo/,followed by a timezone identifier such as "Europe/Berlin" or "Etc/UTC". The resulting link should lead to the corresponding binary tzfile(5) timezone data for the configured timezone.
- Because the timezone identifier is extracted from the symlink target name of /etc/localtime,this file may not be a normal file or hardlink.
- The timezone may be overridden for individual programs by using the TZ environment variable. See environ(7).
- You may use timedatectl(1) to change the settings of this file from the command line during runtime. Use systemd-firstboot(1) to initialize the time zone on mounted (but not booted) system images.
为了确定时区,可以发布the following command:
- [vagrant@localhost ~]$cat /etc/sysconfig/clock
- ZONE="UTC"