Linux修改系统时区

同样以centOS7为例作演示。

timedatectl修改时区

查看系统时间详情
[root@controller ~]# timedatectl
      Local time: Thu 2017-04-06 15:41:23 CST
  Universal time: Thu 2017-04-06 07:41:23 UTC
        RTC time: Thu 2017-04-06 07:41:24
       Time zone: UTC (CST, +0800)
     NTP enabled: no
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
查看系统所有时区
[root@controller ~]# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
...  ...

调整硬件时钟

参数:1 为将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间

[root@controller ~]# timedatectl set-local-rtc 1
[root@controller ~]# timedatectl 
      Local time: Thu 2017-04-06 15:57:27 CST
  Universal time: Thu 2017-04-06 07:57:27 UTC
        RTC time: Thu 2017-04-06 15:57:27
       Time zone: UTC (CST, +0800)
     NTP enabled: no
NTP synchronized: yes
 RTC in local TZ: yes
      DST active: n/a
设置系统时区
[root@controller ~]# timedatectl set-timezone Asia/Shanghai

通过修改时区文件来修改时区(更加通用和简单)

[root@controller ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

你可能感兴趣的:(Linux修改系统时区)