15.5. Synchronizing the Clocks
The
phc2sys program is used to synchronize the system clock to the
PTP
hardware clock (
PHC) on the NIC. To start
phc2sys, where
em3 is the interface with the
PTP
hardware clock, enter the following command as
root
:
~]# phc2sys -s em3 -w
The
-w
option waits for the running
ptp4l application to synchronize the
PTP
clock and then retrieves the
TAI to
UTC offset from
ptp4l.
Normally,
PTP
operates in the
International Atomic Time (
TAI) timescale, while the system clock is kept in
Coordinated Universal Time (
UTC). The current offset between the TAI and UTC timescales is 35 seconds. The offset changes when leap seconds are inserted or deleted, which typically happens every few years. The
-O
option needs to be used to set this offset manually when the
-w
is not used, as follows:
~]# phc2sys -s em3 -O -35
Once the phc2sys servo is in a locked state, the clock will not be stepped, unless the -S
option is used. This means that the phc2sys program should be started after the ptp4l program has synchronized the PTP
hardware clock. However, with -w
, it is not necessary to start phc2sys after ptp4l as it will wait for it to synchronize the clock.
The
phc2sys program can also be started as a service by running:
~]# systemctl start phc2sys
When running as a service, options are specified in the
/etc/sysconfig/phc2sys
file. More information on the different
phc2sys options can be found in the
phc2sys(8)
man page.
Note that the examples in this section assume the command is run on a slave system or slave port.