systemd
Daemonjournalctl
: Query the systemd
Journaludev
The NTP (network time protocol) mechanism is a protocol for synchronizing the system time over the network. First, a machine can obtain the time from a server that is a reliable time source. Second, a machine can itself act as a time source for other computers in the network. The goal is twofold—maintaining the absolute time and synchronizing the system time of all machines within a network.
Maintaining an exact system time is important in many situations. The built-in hardware clock does often not meet the requirements of applications such as databases or clusters. Manual correction of the system time would lead to severe problems because, for example, a backward leap can cause malfunction of critical applications. Within a network, it is usually necessary to synchronize the system time of all machines, but manual time adjustment is a bad approach. NTP provides a mechanism to solve these problems. The NTP service continuously adjusts the system time with reliable time servers in the network. It further enables the management of local reference clocks, such as radio-controlled clocks.
Since openSUSE Leap 15, chrony
is the default implementation of NTP.
chrony
includes two parts; chronyd
is a daemon that can be started at
boot time and chronyc
is a command line interface program to monitor the
performance of chronyd
, and to change various operating parameters at
runtime.
To enable time synchronization by means of active directory, follow the instructions found at Book “Security Guide”, Chapter 7 “Active Directory Support”, Section 7.3.3 “Joining Active Directory Using . ”, Joining an Active Directory Domain Using
The NTP daemon (chronyd
) coming with the chrony
package is preset to use the local computer hardware clock as a time
reference. The precision of a hardware clock heavily depends on its time
source. For example, an atomic clock or GPS receiver is a very precise time
source, while a common RTC chip is not a reliable time source. YaST
simplifies the configuration of an NTP client.
In the YaST NTP client configuration (
› ) window, you can specify when to start the NTP daemon, the type of the configuration source, and add custom time servers.You can choose from three options for when to start the NTP daemon:
Select chrony
daemon.
Select chrony
. You can set
the .
Select chronyd
automatically when the system is booted. This setting is recommended.
In the
drop-down box, select either or . Set if your server uses only a fixed set of (public) NTP servers, while is better if your internal network offers NTP servers via DHCP.Time servers for the client to query are listed in the lower part of the
window. Modify this list as needed with , , and .Click
to add a new time server:In the
field, type the URL of the time server or pool of time servers with which you want to synchronize the machine time. After the URL is complete, click to verify that it points to a valid time source.
Activate chronyd
daemon start.
Activate chronyd
daemon automatically and may not have an
Internet connection at boot time. This option is useful for example for
laptops whose network connection is managed by NetworkManager.
Confirm with
.
chrony
reads its configuration from the
/etc/chrony.conf
file. To keep the computer clock
synchronized, you need to tell chrony
what time servers to use. You can
use specific server names or IP addresses, for example:
server 0.europe.pool.ntp.org server 1.europe.pool.ntp.org server 2.europe.pool.ntp.org
You can also specify a pool name. Pool name resolves to several IP addresses:
pool pool.ntp.org
To synchronize time on multiple computers on the same network, we do not
recommend to synchronize all of them with an external server. A good
practice is to make one computer the time server which is synchronized with
an external time server, and the other computers act as its clients. Add a
local
directive to the server's
/etc/chrony.conf
to distinguish it from an
authoritative time server:
local stratum 10
To start chrony
, run:
systemctl start chronyd.service
After initializing chronyd
, it takes some time before the time is
stabilized and the drift file for correcting the local computer clock is
created. With the drift file, the systematic error of the hardware clock can
be computed when the computer is powered on. The correction is used
immediately, resulting in a higher stability of the system time.
To enable the service so that chrony
starts automatically at boot time,
run:
systemctl enable chronyd.service
chronyd
at Runtime Using chronyc
#Edit source
You can use chronyc
to change the behavior of chronyd
at runtime. It
also generates status reports about the operation of chronyd
.
You can run chronyc
either in interactive or non-interactive mode. To
run chronyc
interactively, enter chronyc
on the command line. It
displays a prompt and waits for your command input. For example, to check
how many NTP sources are online or offline, run:
root #
chronyc
chronyc> activity 200 OK 4 sources online 2 sources offline 1 sources doing burst (return to online) 1 sources doing burst (return to offline) 0 sources with unknown address
To exit chronyc
's prompt, enter quit
or
exit
.
If you do not need to use the interactive prompt, enter the command directly:
root #
chronyc
activity
Changes made using chronyc
are not permanent. They will be lost after the
next chronyd
restart. For permanent changes, modify
/etc/chrony.conf
.
For a complete list of chronyc
commands, see its manual page (man
1 chronyc
).
If the system boots without network connection, chronyd
starts up, but it
cannot resolve DNS names of the time servers set in the configuration file.
This can happen if you use NetworkManager with an encrypted Wi-Fi.
chronyd
keeps trying to resolve the time server names specified by the
server
, pool
, and peer
directives in an increasing time interval until it succeeds.
If the time server will not be reachable when chronyd
is started, you can
specify the offline
option:
server server_address offline
chronyd
will then not try to poll the server until it is enabled using the
following command:
root #
chronyc online server_address
When the auto_offline
option is set, chronyd
assumes that
the time server has gone offline when two requests have been sent to it
without receiving a response. This option avoids the need to run the
'offline' command from chronyc
when disconnecting the network link.
The software package chrony
relies on other programs (such as
gpsd
) to access the timing data via the SHM or SOCK
driver. Use the refclock
directive in
/etc/chrony.conf
to specify a hardware reference clock
to be used as a time source. It has two mandatory parameters: a driver name
and a driver-specific parameter. The two parameters are followed by zero or
more refclock
options. chronyd
includes the following
drivers:
PPS - driver for the kernel 'pulse per second' API. For example:
refclock PPS /dev/pps0 lock NMEA refid GPS
SHM - NTP shared memory driver. For example:
refclock SHM 0 poll 3 refid GPS1 refclock SHM 1:perm=0644 refid GPS2
SOCK - Unix domain socket driver. For example:
refclock SOCK /var/run/chrony.ttyS0.sock
PHC - PTP hardware clock driver. For example:
refclock PHC /dev/ptp0 poll 0 dpoll -2 offset -37 refclock PHC /dev/ptp1:nocrossts poll 3 pps
For more information on individual drivers' options, see man 8
chrony.conf
.