Centos7设置时间和时区

 
本文介绍了,在CentOS7 中,如何设置时间,配置时区,设置时间同步 和 开启系统、硬件时间同步。
 
Centos7设置时间和时区

 
1、Centos 设置时间:
 
设置时间使用Timedatectl直接设置:
 
timedatectl set-time "2015-07-21"
timedatectl set-time "18:23:51"
timedatectl set-time "2015-07-21 18:23:54"
date
Tue Jul 21 18:23:58 CST 2015

 2、Centos 设置时区:
 
Timedatectl命令可以对系统时间进行全面的配置,设置时区也是非常基本的时间配置之一。以中国标准时间为例,首先找到相应的时区代码,然后进行相关的时区设置。
 
[root@localhost ~]# timedatectl list-timezones | grep Shanghai
Asia/Shanghai
[root@localhost ~]# timedatectl set-timezone "Asia/Shanghaix"
Failed to set time zone: Invalid time zone 'Asia/Shanghaix'
[root@localhost ~]# timedatectl set-timezone "Asia/Shanghai"
4、Centos 时间同步

Centos7推荐使用Chrony。
 
安装Chrony时间同步服务,并开启相关服务:
 
[root@localhost ~]# yum install chrony -y
[root@localhost ~]# systemctl start chronyd
[root@localhost ~]# systemctl enable chronyd
[root@localhost ~]# timedatectl status
Local time: Sun 2015-07-22 20:17:44 CST
Universal time: Sun 2015-07-22 12:17:44 UTC
RTC time: Sun 2015-07-22 12:17:43
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: yes
DST active: n/a

Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.

5、Centos 系统、硬件时间同步:
 
[root@localhost ~]# timedatectl set-local-rtc 1

 
 
 

0 个评论

要回复文章请先登录注册