
linux系统下默认安装了ntp服务,手动进行ntp同步如下$ntpdate ntp1nlnet
当然,也可以指定其它的ntp服务器公网上的NTP服务器列表: >
解决方案:
在linux 上配置NTP 时间同步,具休 *** 作步骤,整理如下:
1 安装软件包(在服务端和客户端):
yum install ntp
2 服务器端配置
例如:
首先,服务端设定IP地址为:192168146110
修改ntp配置文件
vim /etc/ntpconf
server 0redhatpoolntporg //设定上级服务器
restrict 1921681460 mask 2552552550 nomodify //设定哪些client机器可以和ntp server进行同步
//启动NTP服务前,手动校正一次时间
ntpdate 0redhatpoolntporg
service ntpd restart
chkconfig ntpd on
//查看ntp服务状态
netstat -ln | grep 123
ntpstat
3客户端配置:
ntpdate 192168146110 //与NTP server 同步时间
或者定期同步
crontab -e
/5 /usr/sbin/ntpdate -u 192168146110 //每五分钟同步一次
重启crond服务/etc/initd/crond restart
ntpq -p //查看同步状态
大体思路:
1、根据ntp获取网络时间
2、判断当前系统是windows还是Linux
3、拼接命令cmd,通过RuntimegetRuntime()exec(cmd)执行命令
参考:Java修改系统时间
以上就是关于Linux系统下的NTP配置全部的内容,包括:Linux系统下的NTP配置、使用ntpdate命令同步时间后,时间还是不准确问题的解决、linux系统上验证系统时间和ntp server的时间是否一致。等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)