linux 搭建ntp服务器

  首先安装ntp server, 

yum install -y ntp

  修改ntp server 配置文件,

vi /etc/ntp.conf

###change for self-network
# Hosts on local network are less restricted.
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

    配置server端硬件时间同步,

vi /etc/sysconfig/ntpd
###modify
# Set to 'yes' to sync hw clock after successful ntpdate
SYNC_HWCLOCK=yes

  启动ntpd服务,

service ntpd start

  ntpd客户端同步时间,

ntpdate 218.202.111.5

  写入硬件时间,

hwclock -w

  客户端时间周期自动同步,

crontab -e

###append
*/2 * * * * /usr/sbin/ntpdate 218.202.111.5 && /sbin/hwclock -w

 

 

posted on 2014-03-11 17:22  黑猫警长V5  阅读(258)  评论(0编辑  收藏  举报

导航