1.检查系统是否安装了NTP包,没有安装我们直接使用yum命令在线安装: yum install ntp
见参考,ntp是逐渐同步,ntpdate 是直接修改
2,service --status-all 查看开启了哪些服务
3,如果ntp未开启,则开启此服务 service ntpd start
4,设置ntp服务开机自启动chkconfig ntpd on
直接修改硬件时间与系统时间一致
[root@localhost ~]# timedatectl set-local-rtc 1
或者
[root@localhost ~]# hwclock --systohc --localtime
5,系统时间与硬件时间同步:
ntp服务,默认只会同步系统时间。如果想要让ntp同时同步硬件时间linux 同步时间,可以设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中,添加 SYNC_HWCLOCK=yes 这样linux 同步时间,就可以让硬件时间与系统时间一起同步。
6,与互联网标准时间进行同步 ntpdate time.windows.com
或 ntpdate cn.pool.ntp.org
如果端口被占用则,停止占用端口的进程,再执行
yum install lsof
lsof -i:123 查看123端口使用情况
kill -9 xxx杀死进程
ntpdate time.windows.com 同步时间
7,设置自动同步(定时任务,每隔一小时同步。。)
vi /etc/crontab
00 0 1 * * ntpdate -s time.windows.com #每天凌晨1点
* */1 * * * ntpdate -s time.windows.com #每一个小时
* */1 * * * ntpdate -s cn.pool.ntp.org
8,重启linux,测试系统时间与硬件时间同步。
其他:查看系统时间 date 查看硬件时间 clock
有时候时间同步失败,可能并不是系统的问题,可能是时区不对
见参考
文章链接:https://www.fzvps.com/47833.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。
评论前必须登录!
注册