ntp时间同步服务器

[root@localhost ~]# ntpdate time.nist.gov

虚拟机时间不对   自动同步   sudo ntpdate asia.pool.ntp.org

要是同步后时间还是不对可能是时区没设置好

zzx@zzx120:~$           sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime   //调整时区               再 sudo ntpdate -u time.twc.weather.com

ubuntu server ntp时间同步服务器安装及使用           date

 1 * * * * ntpdate asia.pool.ntp.org

crontab中写同步    * * * * * /sbin/ntpdate time.nist.gov  # /sbin/一定要加

手动修改系统时间 date -s 07/11/98

~~~~~~~~~~~~~~~~~~~

网络同步 ntpdate 210.72.145.44

手动同步   date -s "20091112 18:30:50" &&hwclock --systohc

~~~~~~~~~~~~~~~~~~~~

一、服务端

1 apt-get install ntp

 

2 安装后默认启动服务,如果没有启动,启动之。

/etc/init.d/ntp start

 

3 vi /etc/ntp.conf 修改为如下

 

restrict default nomodify notrap noquery

restrict 127.0.0.1

restrict 10.91.0.0 mask 255.255.255.0 nomodify

server 0.pool.ntp.org

server 1.pool.ntp.org

server 2.pool.ntp.org

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10

 

driftfile /var/lib/ntp/drift

broadcastdelay  0.008

keys            /etc/ntp/keys

4 重启ntp服务

 

/etc/init.d/ntp restart

 

 二、客户端

 

1 使用ntpdate命令,如果不存在这个命令,则先安装apt-get install ntp

 

/usr/sbin/ntpdate 10.91.0.10 //即使用ip为10.91.0.10的ntp服务器同步时间

 

2 设置定时同步。

 

vi /etc/crontab

30 01 * * * /usr/sbin/ntpdate 10.91.0.10

 

系统便会在每天早上1点30分自动将系统时间同步到ntp服务器的时间。

 

当然这里crontab的时间是指客户端的时间,同步后等同于ntp服务器的时间。

posted on 2014-10-22 18:36  寒星12345678999  阅读(377)  评论(1编辑  收藏  举报