linux时间同步

服务器安装(linux)

要安装ntp 的rpm 包
1、将ntp.conf覆盖/etc/ntp.conf

ntp.conf如下:

# A very simple client-only ntp configuration.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 8
driftfile /etc/ntp/drift
broadcast 172.16.4.255
restrict default ignore
restrict default nomodify notrap
restrict 172.16.4.0 mask 255.255.255.0
authenticate no


2、为了使NTP服务可以在系统引导的时候自动启动,执行:
  # chkconfig ntpd on
3、启动/关闭/重启NTP的命令是:
  # /etc/init.d/ntpd start
  # /etc/init.d/ntpd stop
  # /etc/init.d/ntpd restart
4、使用下面的命令检查时间服务器同步的状态
# ntpq -p
5、使用下面的命令来检查NTP服务是否启动
# netstat -an |grep 123

ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。

客服端安装(每隔一个小时更新一次时间)
1、将ntpdatecron上传到/etc/cron.hourly
    chmod +x  /etc/cron.hourly/ntpdatecron

 

ntpdatecron如下:

#!/bin/sh

/usr/sbin/ntpdate 172.16.6.45
/usr/sbin/ntpdate 172.16.6.45
2、要启动 cron务,使用以下命令。
   /sbin/service crond start
   要停止该服务,使用以下命令。
   /sbin/service crond stop

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值