Centos7修改时区、时间

米斯特程序猿 2020年12月11日 440次浏览

timedatectl 查看时间信息

[root@vtlee ~]# timedatectl
      Local time: Fri 2020-12-11 01:19:07 EST
  Universal time: Fri 2020-12-11 06:19:07 UTC
        RTC time: Fri 2020-12-11 06:19:07
       Time zone: America/New_York (EST, -0500)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2020-11-01 01:59:59 EDT
                  Sun 2020-11-01 01:00:00 EST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2021-03-14 01:59:59 EST
                  Sun 2021-03-14 03:00:00 EDT

timedatectl 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间

[root@vtlee ~]# timedatectl set-local-rtc 1

timedatectl 修改本机时区

[root@vtlee ~]# timedatectl set-timezone Asia/Shanghai

同步本机时间

[root@vtlee ~]# ntpdate ntp1.aliyun.com
11 Dec 14:20:13 ntpdate[7704]: adjust time server 120.25.115.20 offset 0.003745 sec
[root@vtlee ~]# date
Fri Dec 11 14:20:22 CST 2020

ntpdate 工具安装方法

yum -y install ntp

参考