共计 1027 个字符,预计需要花费 3 分钟才能阅读完成。
server 服务器每 1 个小时更新一次时间,server 服务器旗下同步服务器每 5 秒钟同步一次时间,同步服务器与外网不做交互,由 server 服务器进行同步时间。所以保证每一台同步服务器时间一致。
#vi ud_ntp.sh
#!/bin/bash
time=5
ip(){
echo “192.168.48.114”
echo “192.168.28.233”
}
stp(){
/etc/init.d/ntpd stop
}
upd(){
ntpdate us.pool.ntp.org
}
stt(){
/etc/init.d/ntpd start
}
num=`ps -ef | grep ntpd.pid | grep -v grep`
not(){
if [! -n “$num”]; then
# echo “IS NULL”
upd
stt
else
# echo “NOT NULL”
stp
upd
stt
fi
}
ntp(){
while true
do
sleep $time
for i in `ip`
do
ssh $i ntpdate 192.168.48.117
if [[00 == `date | awk -F “:” ‘{print $2}’` ]]
then
not
sleep 240
break
fi
done
done
}
ntp&
还有什么考虑不周全的地方,大家指正!
CentOS NTP 服务器安装与配置 http://www.linuxidc.com/Linux/2014-01/95258.htm
Linux 实战部署系列之 NTP 服务器 http://www.linuxidc.com/Linux/2013-11/92275.htm
多种操作系统 NTP 客户端配置 http://www.linuxidc.com/Linux/2013-10/91928.htm
搭建企业级 NTP 时间服务器 http://www.linuxidc.com/Linux/2014-02/97205.htm
Linux 下快速搭建 ntp 时间同步服务器 http://www.linuxidc.com/Linux/2014-07/104371.htm
CentOS 6.3 下实现 NTP 时间服务器 http://www.linuxidc.com/Linux/2014-08/105414.htm
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-04/116147.htm
