linux下时间同步配置

在 Linux 上面进行网络校准时间,   
210.72.145.44 为中国国家授时中心服务器地址。 直接以 ntpdate 这个指令来手动执行即可:
[root@localhost gd]# ntpdate  cn.pool.ntp.org
26 Oct 09:21:03 ntpdate[3962]: adjust time server 122.226.192.4 offset -0.007338 sec
[root@localhost gd]# 
cn.pool.ntp.org :为标准时间服务器。
也可以把上面的命令放入到crontab中进行定时自动校准时间。但是这样校准的时间不是平滑变动的,会影响程序的执行。
=================================
我们可以通过ntpd服务进行平滑校准时间。首先确保linux系统已经安装ntpd服务。设置ntp.cnf文件。(/etc/ntp.cnf)修改其中的server,并删除多余的server
#  server cn.pool.ntp.org prefer
保存退出。启动ntpd服务。可以通过 ntpq -p或者 ntpstat进行查看校准信息
命令 ntpstat :
[root@localhost gd]# ntpstat 
synchronised to NTP server (122.226.192.4) at stratum 3 
   time correct to within 460 ms
   polling server every 64 s
命令 ntpdq -p :
[root@localhost gd]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*122.226.192.4   127.67.113.92    2 u    9   64   77   15.145   -5.967   1.138
[root@localhost gd]# 

实现了linux系统时间的校准,一般在使用ntpd之前会用ntpdate进行手动校对。

你可能感兴趣的:(linux下时间同步配置)