Verificando o status
Desde o Ubuntu 16.04 timesyncd, que faz parte do systemd, é agora responsável (fora da caixa) por sincronizar data / hora. Você pode verificar seu status usando systemctl
:
$ systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: active (running) since Sun 2018-08-05 10:14:44 EDT; 11min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 3714 (systemd-timesyn)
Status: "Synchronized to time server 108.59.2.24:123 (0.debian.pool.ntp.org)."
CGroup: /system.slice/systemd-timesyncd.service
└─3714 /lib/systemd/systemd-timesyncd
Aug 05 10:14:44 pi-hole systemd[1]: Starting Network Time Synchronization...
Aug 05 10:14:44 pi-hole systemd[1]: Started Network Time Synchronization.
Aug 05 10:14:45 pi-hole systemd-timesyncd[3714]: Synchronized to time server 108.59.2.24:123 (0.debian.pool.ntp.org).
Ou até journalctl
:
$ journalctl -u systemd-timesyncd
-- Logs begin at Thu 2016-11-03 13:16:42 EDT, end at Sun 2018-08-05 10:20:01 EDT. --
Aug 05 10:14:44 pi-hole systemd[1]: Starting Network Time Synchronization...
Aug 05 10:14:44 pi-hole systemd[1]: Started Network Time Synchronization.
Aug 05 10:14:45 pi-hole systemd-timesyncd[3714]: Synchronized to time server 108.59.2.24:123 (0.debian.pool.ntp.org).
Você também pode assistir a systemd/clock
:
$ stat /var/lib/systemd/clock
File: /var/lib/systemd/clock
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: b302h/45826d Inode: 18750 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 100/systemd-timesync) Gid: ( 103/systemd-timesync)
Access: 2018-08-05 10:22:13.838262405 -0400
Modify: 2018-08-05 10:22:13.838262405 -0400
Change: 2018-08-05 10:22:13.838262405 -0400
Birth: -
Os horários de acesso / modificação / alteração neste arquivo são exibidos quando o systemd-timesy é acessado pela última vez.
Forçando uma sincronização
Não parece haver qualquer método para forçar uma sincronização diretamente. Reiniciar o serviço systemd-timesyncd
, na verdade, aciona uma ressincronização:
$ systemctl restart systemd-timesyncd
Você pode ver isso nos registros:
$ journalctl -u systemd-timesyncd
-- Logs begin at Thu 2016-11-03 13:16:42 EDT, end at Sun 2018-08-05 10:44:37 EDT. --
Aug 05 10:14:44 pi-hole systemd[1]: Starting Network Time Synchronization...
Aug 05 10:14:44 pi-hole systemd[1]: Started Network Time Synchronization.
Aug 05 10:14:45 pi-hole systemd-timesyncd[3714]: Synchronized to time server 108.59.2.24:123 (0.debian.pool.ntp.org).
Aug 05 10:44:37 pi-hole systemd[1]: Stopping Network Time Synchronization...
Aug 05 10:44:37 pi-hole systemd[1]: Stopped Network Time Synchronization.
Aug 05 10:44:37 pi-hole systemd[1]: Starting Network Time Synchronization...
Aug 05 10:44:37 pi-hole systemd[1]: Started Network Time Synchronization.
Aug 05 10:44:37 pi-hole systemd-timesyncd[4157]: Synchronized to time server 208.75.88.4:123 (0.debian.pool.ntp.org).
A última linha é da minha reinicialização.
Intervalo de controle
Você pode controlar o intervalo em que os servidores NTP são pesquisados por meio dessas propriedades no arquivo systemd-timesyncd
config /etc/systemd/timesyncd.conf
:
PollIntervalMinSec=, PollIntervalMaxSec= The minimum and maximum poll intervals for NTP messages. Each setting takes a time value (in seconds). PollIntervalMinSec= must not be smaller than 16 seconds. PollIntervalMaxSec= must be larger than PollIntervalMinSec=. PollIntervalMinSec= defaults to 32 seconds, and PollIntervalMaxSec= defaults to 2048 seconds.
O texto acima parece ter sido adicionado no final de 2017 - timesync: torna o intervalo de sondagem configurável # 7268 .