问题描述
通过点击“系统设置 – >时间和日期 – >自动从互联网”,我可以从互联网同步时间。
但是,我发现我没有ntpd
守护进程(它甚至没有安装)。那么同步如何工作呢?
最佳解决方法
这是通过与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
TIME-SERVER列表可以创建here
次佳解决方法
每次网络连接启动时,Ubuntu都会与ntpdate
实用程序同步(通常在启动时发生)。
默认情况下安装此实用程序,但仅在Ubuntu调用它时运行,并且不作为守护程序在后台运行。
安装ntp
软件包会安装NTP守护程序。 ntp守护程序允许在系统运行时持续同步时间。
更新:在最新版本的Ubuntu(如16.04)ntpdate
由timedatectl
,其在引导synchonises一旦以及当网络出现的,但不保留在其他时间运行取代。有关更多信息,请参阅https://help.ubuntu.com/lts/serverguide/NTP.html。
第三种解决方法
对于那些拥有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
更多信息:Time Synchronisation with NTP和timedatectl
第四种方法
另请注意,对于未安装的服务,完全可能存在front-end接口。
您可以根据需要更改该front-end(GUI)界面中的设置,但如果未安装实际执行任务的服务,则不会发生任何操作。
但请注意,我认为”switch”是有效的,因为它告诉它在每次启动时执行one-time更新。 (或不这样做)。
除非这是一个not-network连接系统,或者还有一些其他重要原因没有将其时间设置为匹配”standard”时间,我强烈建议您安装ntpd,并正确配置并运行它。