Nesse artigo vou falar do serviço de sincronia de horário que está disponível no ubuntu 18 e derivados.
Iniciando.
Vamos ativar o serviço systemd-timesyncd .
systemctl enable --now systemd-timesyncd.service
root@srv01:~# systemctl enable --now systemd-timesyncd.service
Vamos definir o seu timezone
timedatectl set-timezone America/Maceio
Na dúvida .
timedatectl list-timezones
As principais nacionais são :
America/Bahia America/Maceio America/Manaus America/Porto_Velho America/Recife America/Sao_Paulo
Vamos editar o arquivo timesyncd.conf
vi /etc/systemd/timesyncd.conf
Colocar o seguinte conteúdo.
# # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Entries in this file show the compile time defaults. # You can change settings by editing this file. # Defaults can be restored by simply deleting this file. # # See timesyncd.conf(5) for details. [Time] NTP=pool.ntp.br FallbackNTP=ntp.ubuntu.com RootDistanceMaxSec=5 PollIntervalMinSec=32 PollIntervalMaxSec=2048
Vamos ativar via timedatectl.
timedatectl set-ntp true
Reiniciar o serviço.
systemctl restart systemd-timesyncd.service
Verificar o status .
systemctl status systemd-timesyncd.service
julio@srv01:~$ 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 Mon 2019-11-18 10:16:50 -03; 24min ago Docs: man:systemd-timesyncd.service(8) Main PID: 2297 (systemd-timesyn) Status: "Synchronized to time server 200.20.186.76:123 (pool.ntp.br)." Tasks: 2 (limit: 2290) CGroup: /system.slice/systemd-timesyncd.service └─2297 /lib/systemd/systemd-timesyncd Nov 18 10:16:50 srv01 systemd[1]: Starting Network Time Synchronization... Nov 18 10:16:50 srv01 systemd[1]: Started Network Time Synchronization. Nov 18 10:16:50 srv01 systemd-timesyncd[2297]: Synchronized to time server 200.20.186.76:123 (pool.ntp.br).
Verificar o status via timedatectl.
timedatectl status
julio@srv01:~$ timedatectl status Local time: Mon 2019-11-18 10:40:22 -03 Universal time: Mon 2019-11-18 13:40:22 UTC RTC time: Mon 2019-11-18 13:40:22 Time zone: America/Maceio (-03, -0300) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no