Linux同步网络时间

虚拟机时间同步:

[root@localhost ~]# date
Thu Jul 18 20:04:44 CST 2019

时间与本地计算机时间快了9小时,查看网上类似问题方案是同步远端服务器的时间

ntp常用服务器

中国国家授时中心:210.72.145.44
NTP服务器(上海) :ntp.api.bz

美国:time.nist.gov 
复旦:ntp.fudan.edu.cn 
微软公司授时主机(美国) :time.windows.com 
台警大授时中心(台湾):asia.pool.ntp.org

尝试修改时间:

下载时间同步模块

# yum install ntpdate ntp -y

尝试同步远程服务器

# ntpdate -u 210.72.145.44

[root@localhost ~]# ntpdate -u 210.72.145.44
18 Jul 20:11:32 ntpdate[20364]: no server suitable for synchronization found

 

尝试修改文件:

# ntpdate -u ntp.api.bz

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

# ntpdate pool.ntp.org

[root@localhost ~]# ntpdate -u ntp.api.bz
18 Jul 11:14:25 ntpdate[20390]: step time server 114.118.7.161 offset -32392.117785 sec
[root@localhost ~]# date
Thu Jul 18 11:14:37 CST 2019
[root@localhost ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp: ‘/usr/share/zoneinfo/Asia/Shanghai’ and ‘/etc/localtime’ are the same file
[root@localhost ~]# ntpdate pool.ntp.org
18 Jul 11:15:37 ntpdate[20401]: adjust time server 120.25.115.20 offset 0.000914 sec
[root@localhost ~]# date
Thu Jul 18 11:15:46 CST 2019
[root@localhost ~]#

 

写入定时任务同步时间
/10 * /usr/sbin/ntpdate asia.pool.ntp.org &>/dev/null 
重启定时任务服务
service crond restart

参考博客:

Linux 修正时间并与网络时间同步

https://blog.51cto.com/13718210/2176491

linux时间同步

转载于:https://www.cnblogs.com/djlsunshine/p/11206163.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值