更新时间和时间同步
1.查看系统时间
[root@localhost ~]# date
2019年 07月 10日 星期三 11:22:44 CST
2.查看硬件时间
[root@localhost ~]# hwclock
2019年07月10日 星期三 11时24分11秒 -0.618165 秒
3.查看系统时间方面的各种状态
[root@localhost ~]# timedatectl
Local time: 三 2019-07-10 11:25:08 CST
Universal time: 三 2019-07-10 03:25:08 UTC
RTC time: 三 2019-07-10 03:25:08
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
4.列出所有时区
[root@localhost ~]# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
...........
5.将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间
[root@localhost ~]# timedatectl set-local-rtc 0
[root@localhost ~]# timedatectl
Local time: 三 2019-07-10 11:29:10 CST
Universal time: 三 2019-07-10 03:29:10 UTC
RTC time: 三 2019-07-10 03:29:10
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
6.安装ntp工具
yum -y install utp ntpdate
7.设置系统时间与网络时间同步
[root@localhost ~]# ntpdate cn.pool.ntp.org
10 Jul 14:44:06 ntpdate[24742]: adjust time server 119.28.206.193 offset -0.020508 sec
[root@localhost ~]# date
2019年 07月 10日 星期三 14:44:11 CST
8.将时间写入硬件时间
[root@localhost ~]# hwclock --systohc
9.设置系统时区为上海
[root@localhost ~]# timedatectl set-timezone Asia/Shanghai