Chinaunix首页 | 论坛 | 博客
  • 博客访问: 18762
  • 博文数量: 19
  • 博客积分: 301
  • 博客等级: 二等列兵
  • 技术积分: 170
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-26 10:30
文章分类
文章存档

2011年(19)

我的朋友
最近访客

分类:

2011-04-27 14:07:49

原文地址:机器时间同步策略分析 作者:xyaxlz

10.10.10.70是ntp时间同步服务器,10.70与国家授时中心(210.72.145.44)时间同步。其他机器设置与10.10.10.70机器时间同步。
 
一、在10.10.10.70的crontab中有关时间服务器的设置,如下。
 

1ntprestart.sh脚本在crontab中的配置:

10 22 * * * /root/ntprestart.sh

   作用:与ntp服务器同步时间。脚本每天22:10会先停掉本机ntpd进程,再用ntpdatentp210.72.145.44国家授时中心)服务器上取得时间初值,然后启动ntpd服务。

 

/root/ntprestart.sh脚本源码

#!/bin/sh

source /etc/profile

source /root/.bash_profile

service ntpd stop

sleep 5

/usr/sbin/ntpdate 210.72.145.44 >> /usr/local/www/html/ntpmon.log.txt

sleep 5

service ntpd start

#####################################################################

 

2、每天23:00与国家授时中心同步一次。Crontab中的设置

0 23 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1

 

3、每天23:05以系统时间为基准设置硬时钟

5 23 * * * hwclock –w

 

二、在其它机器有关时间同步的设置(crontab中)

 

#ntp

 

*/10 * * * * /usr/sbin/ntpdate 10.10.10.70 > /dev/null 2>&1

作用每10min中与时间服务器10.10.10.70时间服务器同步一次。

 

5 23 * * *  hwclock -w

每天23:05以系统时间为基准设置硬时钟

阅读(453) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~