timesyncd
Sat, Nov 14, 2020 · 2 minute readlinuxlxcvirtualbox
As a general rulle, keeping all your hosts time in sync is a good thing.
Linux variants running systemd will typically use timesyncd for this.
Check the status of timesyncd
# timedatectl timesync-status
Server: 91.189.89.198 (ntp.ubuntu.com)
Poll interval: 34min 8s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 2
Reference: 11FD6C7D
Precision: 1us (-23)
Root distance: 32.569ms (max: 5s)
Offset: +68us
Delay: 14.613ms
Jitter: 41.638ms
Packet count: 256
Frequency: -21.021ppm
Note that the NTP server being used is the default for an Ubuntu install, ntp.ubuntu.com
This particular server is running a lot of LXC containers, one of which runs CCTV software.
As it turns out, RTSP streams for IP cameras are time sensitive. If the sending and receiving host times are not in sync then there will be problems with the RTSP feed, e.g. Invalid data found when processing input
.
Containers are prevented from running timesyncd by the service configuration, ConditionVirtualization=!container
so they get their time from the host.
While this particular host was running timesynd and it appeared to be working the time was still drifting enough to affect RTSP streams from the container.
Updated the timesyncd configuration and changed the NTP servers which appears to have fixed the problem.
Before
# cat /etc/systemd/timesyncd.conf
[Time]
#NTP=
...
After
[Time]
NTP=0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org
Restart timesyncd and check the status
# systemctl restart systemd-timesyncd.service
# systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-11-14 09:43:16 GMT; 6s ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 3666655 (systemd-timesyn)
Status: "Initial synchronization to time server 217.114.59.3:123 (0.pool.ntp.org)."
Tasks: 2 (limit: 4620)
Memory: 1.6M
CGroup: /system.slice/systemd-timesyncd.service
└─3666655 /lib/systemd/systemd-timesyncd
Nov 14 09:43:16 vh1 systemd[1]: Starting Network Time Synchronization...
Nov 14 09:43:16 vh1 systemd[1]: Started Network Time Synchronization.
Nov 14 09:43:16 vh1 systemd-timesyncd[3666655]: Initial synchronization to time server 217.114.59.3:123 (0.pool.ntp.org).
# timedatectl timesync-status
Server: 217.114.59.3 (0.pool.ntp.org)
Poll interval: 1min 4s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 2
Reference: 9D2CB004
Precision: 1us (-20)
Root distance: 23.894ms (max: 5s)
Offset: +844us
Delay: 21.315ms
Jitter: 0
Packet count: 1
Frequency: -14.420ppm