通过点击“系统设置->时间和日期->自动从互联网获取”我可以从互联网同步时间。
但是我发现我没有ntpd
守护进程(甚至没有安装)。那么同步是如何工作的呢?
答案1
这是通过与 ntpdate
工具同步来完成的。
man ntpdate
NAME
ntpdate - set the date and time via NTP
ntpdate sets the local date and time by polling the Network Time Proto‐
col (NTP) server(s) given as the server arguments to determine the cor‐
rect time. It must be run as root on the local host (unless the option
-q is used). A number of samples are obtained from each of the servers
specified and a subset of the NTP clock filter and selection algorithms
are applied to select the best of these. Note that the accuracy and
reliability of ntpdate depends on the number of servers, the number of
polls each time it is run and the interval between runs.
ntpdate can be run manually as necessary to set the host clock, or it
can be run from the host startup script to set the clock at boot time.
This is useful in some cases to set the clock initially before starting
the NTP daemon ntpd. It is also possible to run ntpdate from a cron
script. However, it is important to note that ntpdate with contrived
cron scripts is no substitute for the NTP daemon, which uses sophisti‐
cated algorithms to maximize accuracy and reliability while minimizing
resource use. Finally, since ntpdate does not discipline the host clock
frequency as does ntpd, the accuracy using ntpdate is limited.
你可以这样做
sudo ntpdate TIME-SERVER
可以建立“时间服务器”列表这里
答案2
ntpdate
每次网络连接建立时(通常在启动时发生),Ubuntu 都会与实用程序同步一次。
该实用程序默认安装,但仅在 Ubuntu 调用它时运行,并且不会作为守护进程在后台运行。
安装此ntp
软件包会安装 NTP 守护进程。ntp 守护进程允许在系统运行时持续同步时间。
更新:在较新版本的 Ubuntu(例如 16.04)中,ntpdate
被 取代timedatectl
,它会在启动时以及网络启动时同步一次,但在其他时间不会继续运行。请参阅https://help.ubuntu.com/lts/serverguide/NTP.html了解更多信息。
答案3
对于使用 16.04 LTS 的用户,时间同步似乎由 sytemd 处理,特别是“timedatectl”
timedatectl status
Local time: Wed 2016-11-30 17:45:18 CST
Universal time: Wed 2016-11-30 23:45:18 UTC
RTC time: Sun 2016-12-04 06:50:39
Time zone: America/Chicago (CST, -0600)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
配置是
/etc/systemd/timesyncd.conf
更多信息请点击这里:使用 NTP 进行时间同步 和timedatectl
答案4
参考:https://help.ubuntu.com/community/UbuntuTime
Ubuntu 标配 ntpdate,并在启动时运行一次,根据 Ubuntu 的 NTP 服务器设置您的时间。但是,如果重新启动间隔时间很长,系统时钟在重新启动之间可能会有很大偏差。在这种情况下,偶尔纠正时间是有意义的。最简单的方法是让 cron 每天运行它。
ntpdate ntp.ubuntu.com