服务器时间同步

2021年09月21日

NTP

NTP 是一种 TCP/IP 协议,用于通过网络同步时间

ubuntu 时间同步

相关服务和工具

由于 Ubuntu 16.04 timedatectl / timesyncd(它们是 systemd 的一部分)替换了大部分ntpdate / ntp。


timedatectl  -h #查看帮助

systemctl status systemd-timesyncd # 查看时间同步服务状态

同步服务配置文件

NAME
       timesyncd.conf, timesyncd.conf.d - Network Time Synchronization configuration files

SYNOPSIS
       /etc/systemd/timesyncd.conf

       /etc/systemd/timesyncd.conf.d/*.conf

       /run/systemd/timesyncd.conf.d/*.conf

       /usr/lib/systemd/timesyncd.conf.d/*.conf

修改NTP= FallbackNTP= 可以修改同步时间服务器(NTP)

timesyncd.conf默认配置


#  This file is part of systemd.
# 
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See timesyncd.conf(5) for details.

[Time]
#NTP=ntp.ubuntu.com
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048