centos6:
修改時間:date -s "2020-04-17 16:01:40"
同步系統時間到硬件時間:hwclock --hctosys
顯示硬件時間:hwclock --show
centos7:
1、查看當前的系統時間:
[root@bogon vagrant]# date
Tue Jun 25 12:12:23 UTC 2019
2、 查看當前時區
[vagrant@bogon ~]$ timedatectl status
Local time: Tue 2019-06-25 20:29:47 CST
Universal time: Tue 2019-06-25 12:29:47 UTC
RTC time: Tue 2019-06-25 12:29:50
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'.
3、修改時間
[root@bogon vagrant]# date -s "2019-06-25 20:13:00"
Tue Jun 25 20:13:00 UTC 2019
4、修改時區
[root@bogon vagrant]# timedatectl set-timezone Asia/Shanghai
5、 查看硬件時間
[root@bogon vagrant]# hwclock --show
Tue 25 Jun 2019 08:13:56 PM CST -0.891529 seconds
6、 同步系統時間和硬件時間
[root@bogon vagrant]# hwclock --hctosys
7、 本地時間寫入硬件時間
[root@bogon vagrant]# timedatectl set-local-rtc 1
[root@bogon vagrant]# date
Tue Jun 25 20:14:35 CST 2019
8、重啓系統 reboot