linux:~ # cat /etc/ntp.conf | grep -v "^#"
server 127.127.1.0 # local clock (LCL)
fudge 127.127.1.0 stratum 10 # LCL is unsynchronized
restrict default nomodify
server 127.127.1.0
server 127.127.1.0 prefer
driftfile /var/lib/ntp/drift/ntp.drift # path for drift file
logfile /var/log/ntp # alternate log file
keys /etc/ntp.keys # path for keys file
trustedkey 1 # define trusted keys
requestkey 1 # key (7) for accessing server variables
我们可以使用 ntpq 命令来检查本地服务器的时钟如何通过 NTP 同步。
ntpq -p 验证NTP服务器
linux:~ # ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) .LOCL. 10 l 55 64 377 0.000 0.000 0.001
LOCAL(0) .LOCL. 5 l 51 64 377 0.000 0.000 0.001
*LOCAL(0) .LOCL. 5 l 62 64 377 0.000 0.000 0.001
linux:~ #
客户端同步服务器端的时间命令:
redhat系统,
/usr/sbin/ntpdate 192.168.0.80
suse系统:
Callshine:~ # /usr/sbin/sntp 192.168.0.80
可以配置后台任务每5分钟同步一次,
*/5 * * * * /usr/sbin/sntp 192.168.0.80
5,10,15,20,25,30,35,40,45,50,55,0 * * * * /usr/sbin/sntp 192.168.0.80