一:linux分为系统时间和硬件时间

查看系统时间:date

查看硬件时间:hwclock   (hwclock需要root权限)

二:ntpdate同步时间

1.修改ntp.conf文件

vi /etc/ntp.conf

增加server cn.pool.ntp.org prefer

linux使用ntpdate同步日期时间

2.执行ntpdate cn.pool.ntp.org

linux使用ntpdate同步日期时间

注意:

如果出现错误unknown类似错误,解决方法参考地址:https://blog.csdn.net/qq_42957844/article/details/102563900

如果第2步执行后时间不准,可能是时区错误,修改时区

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

linux使用ntpdate同步日期时间

3.查看date,hwclock。

4.同步date与hwclock

以硬件时间为基准,修改系统时间:hwclock -s

以系统时间为基准,修改硬件时间:hwclock -w

相关文章: