博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

配置ntp server and client.

Posted on 2013-02-20 15:37  钟悍  阅读(1857)  评论(0编辑  收藏  举报

sntp -r <ntp server ip> // force ntp client synchronized ntp server.

cd /usr/share/zoneinfo/Asia //
cp Shanghai /etc/localtime // change time zone to CST

hwclock --show // show hardware time.
hwclock --systohc // change hardware time to system time.

ntpq -p // check ntp status.

/etc/init.d/ntp restart // ntp service restart.


ntp server:
add a line 'server 127.127.1.0 mode 5 prefer' to /etc/ntp.conf,
use '/etc/init.d/ntp restart' restart ntp service.
use 'ntpq -p' check the status.
eg:
wing-up-fr-179:/usr/share/zoneinfo/Asia # ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 5 l 16 64 377 0.000 0.000 0.001

if there is a "*" before 'LOCAL(0)', then ntp server is OK, it will take serval minutes.

ntp client:
add a line 'server <ntp server ip>' to /etc/ntp.conf,
use '/etc/init.d/ntp restart' restart ntp service.
use 'sntp -r <ntp server ip>' to force synchronized.