参考:https://blog.csdn.net/u013543480/article/details/42705953
https://www.bbsmax.com/A/D854Pq6x5E/
环境查看

系统时间不对,比正常时间多8小时,使用命令date设置正确时间以后如果系统重启时间又多8小时
查看时间
root@hdy-desktop:~# date
2020年 07月 18日 星期五 18:44:42 CST
root@hdy-desktop:~# timedatectl
Local time: 五 2020-08-17 18:44:55 CST #正常时间应该是10:44显示时间比正常多8小时
Universal time: 五 2020-08-17 10:44:55 UTC
RTC time: 一 2020-08-17 10:44:36
Time zone: Asia/Chongqing (CST, +0800)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
使用命令修改时间
date -s "2020-08-17 10:47:22"
再次查看时间正常
root@hdy-desktop:~# date -s "2020-08-17 10:47:22"
2020年 08月 17日 星期一 10:47:22 CST
root@hdy-desktop:~# timedatectl
Local time: 一 2020-08-17 10:47:49 CST
Universal time: 一 2020-08-17 02:47:49 UTC
RTC time: 一 2020-08-17 10:47:18
Time zone: Asia/Chongqing (CST, +0800)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
重启系统
reboot
再次查看时间又多了8小时
root@hdy-desktop:~# date
2020年 08月 17日 星期一 18:49:40 CST
root@hdy-desktop:~# timedatectl
Local time: 一 2020-08-17 18:49:43 CST
Universal time: 一 2020-08-17 10:49:43 UTC
RTC time: 一 2020-08-17 10:49:43
Time zone: Asia/Chongqing (CST, +0800)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
原因:系统重启以后使用了系统硬件时间作为UTC时间,时区设置为中国时区,所以正常显示CST时间又多了8小时
显示硬件时间
hwclock --show
设置硬件时间
hwclock --set --date "2020-08-17 18:44:22"
把系统时间同步为硬件时间
hwclock --systohc
把硬件时间同步为系统时间
hwclock --hctosys
解决办法:设置系统时间以后同步系统时间为硬件时间
首先设置系统时间
date -s "2020-08-17 10:54:22"
把系统时间同步为硬件时间
hwclock --systohc
重启
reboot
重启以后系统时间及硬件时间一致则正常
root@hdy-desktop:~# date 2020年 08月 17日 星期一 10:56:26 CST root@hdy-desktop:~# hwclock --show 2020-08-17 10:56:34.097219+08:00