centos 8 stream 同步时间 修改时区

centos 8 ntp 已经改为使用 chrony

[root@node01 ~]# dnf -y install chrony
[root@node01 ~]# vi /etc/chrony.conf
# line 3: change to your own NTP server or others in your timezone
#pool 2.centos.pool.ntp.org iburst
pool dlp.srv.world iburst
[root@node01 ~]# systemctl enable --now chronyd
# verify status
[root@node01 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* dlp.srv.world                 2   6    17    11    +22us[  +16us] +/-   11ms

[root@node01 ~]# dnf -y install ntpstat
[root@node01 ~]# ntpstat
synchronised to NTP server (10.0.0.30) at stratum 3
   time correct to within 9 ms
   polling server every 64 s

设置时区

#查看系统当前时区
timedatectl
Local time: Sat 2020-03-21 21:30:22 UTC
           Universal time: Sat 2020-03-21 21:30:22 UTC
                 RTC time: Sat 2020-03-21 21:30:22
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

#想要列出所有可用的时区
timedatectl list-timezones
...
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Whitehorse
America/Winnipeg
...

#修改时区
#例如,想要将系统时区设置为Asia/Shanghai
timedatectl set-timezone Asia/Shanghai

#查看修改结果
timedatectl
[root@localhost log]# timedatectl
               Local time: Tue 2021-01-19 10:29:53 CST
           Universal time: Tue 2021-01-19 02:29:53 UTC
                 RTC time: Tue 2021-01-19 02:29:53
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

同步硬件时钟
hwclock -w

© 2021, 新之助meow. 原创文章转载请注明: 转载自http://www.xinmeow.com

0.00 avg. rating (0% score) - 0 votes
点赞