CentOS 8 常见问题
时间问题
timedatectl
直接显示当前时间,输出中的 RTC in local TZ 表示 RTC 是否为本地时间:
~# timedatectl
               Local time: 三 2022-08-10 18:14:43 CST
           Universal time: 三 2022-08-10 10:14:43 UTC
                 RTC time: 三 2022-08-10 10:14:43
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
设置时区:
~# timedatectl set-timezone Asia/Shanghai
设置 RTC 时区(1 为本地时间,0 为 UTC 时间):
~# timedatectl set-local-rtc 0
设置 RTC 时区操作默认会将系统时间同步到 RTC,增加 --adjust-system-clock 参数则可以反过来将 RTC 时间同步到系统:
~# timedatectl set-local-rtc 1 --adjust-system-clock
时间同步
CentOS 8 默认使用 chrony 替代 ntpd / ntpdate,可以修改 /etc/chrony.conf 配置文件修改同步服务器,例如:
pool ntp.ntsc.ac.cn iburst
用户也可以 systemctl stop chronyd 停止服务之后手工指定服务器同步时间:
~# chronyd -q 'server ntp.ntsc.ac.cn iburst'
chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
System clock wrong by 484.698808 seconds (step)
chronyd exiting