Voir :
man 5 adjtime_configman 4 rtc (Real-Time Clock)
/etc/systemd/timesyncd.conf
[Time] Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org
timedatectl set-ntp true
Diag
systemctl restart systemd-timesyncd systemctl status systemd-timesyncd
TODO
aptitude install ntp
On configure le serveur de temps via le fichier
Notamment les lignes suivantes:
/etc/ntp.conf
# le serveur doit lui aussi se synchroniser server 0.fr.pool.ntp.org # ou debian.pool.ntp.org server 1.fr.pool.ntp.org # ou debian.pool.ntp.org server 2.fr.pool.ntp.org # ou debian.pool.ntp.org server 3.fr.pool.ntp.org # ou debian.pool.ntp.org # Autoriser les autres ordinateurs à ce connecter: restrict 0.0.0.0 mask 0.0.0.0 # Limiter les ordinateurs pouvant se connecter à notre réseau personnel: broadcast 192.168.0.255
Four NTP servers are recommended. See http://support.ntp.org/bin/view/Support/SelectingOffsiteNTPServers
“With two, it is impossible to tell which one is better, because you don't have any other references to compare them with. This is actually the worst possible configuration -- you'd be better off using just one upstream time server and letting the clocks run free if that upstream were to die or become unreachable.”
“Use at least 4 NTP servers”
Ou passer à Chrony
tinker panic 0
“The tinker panic value of 0 tells NTP that no matter what the time offset is, not to panic and exit. This is recommended for virtual machines because virtual machines have no physical clock and can be paused at anytime and started back up hours later.”
Source : https://www.redhat.com/en/blog/avoiding-clock-drift-vms
Voir :
1 - Add the following line to the beginning of the /etc/ntp.conf file
tinker panic 0
2 - Remove or comment the “driftfile”
#driftfile /var/lib/ntp/drift/ntp.drift # path for drift file
3 - Restart the ntpd.service
/bin/systemctl restart ntpd.service
Voir https://www.suse.com/fr-fr/support/kb/doc/?id=000021102
ntpdate -B ajustement progressif
ntpdate -b ajustement brutal
aptitude install ntpdate
Utilisation manuel
/usr/sbin/ntpdate -dvu 192.168.2.11
Automatisation
crontab -e
Ajouter la ligne suivante:
0 3 * * * root /usr/sbin/ntpdate -dv ntp.serveur.org > /dev/null
Tester / simuler / lecture seul / dry-run
ntpdate -q pool.ntp.org
/etc/sysconfig/ntp
SYNC_HWCLOCK=yes
This is an option to ntpdate
Afficher la date et l’heure
date
Si la date est incorrecte, utiliser date MMDDmm
Afficher l’heure du BIOS
hwclock
Commande pour que le BIOS puisse utiliser l’heure du système
hwclock --systohc --utc
Comparaison du temps système et le BIOS
date
hwclock
Vérification dans le fichier /etc/sysconfig/clock
UTC=true
Source: https://www.cyberciti.biz/faq/linux-unix-bsd-is-ntp-client-working/
Commandes pour vérifier
ntpstat
| Exit status | Error |
|---|---|
| 0 | Clock is synchronised. |
| 1 | Clock is not synchronised. |
| 2 | If clock state is indeterminant, for example if ntpd is not contactable |
ntpq -pn
# ntpq -p remote refid st t when poll reach delay offset jitter =========================================== europium.canoni 193.79.237.14 2 u 15 64 1 28.682 -3.649 0.015 horlogegps.rese 10.3.128.189 2 u 14 64 1 29.002 -11.238 0.015 kontir.mkc.fr 213.251.128.249 2 u 13 64 1 76.501 18.866 0.015 dnscache-london 140.203.16.5 2 u 12 64 1 58.209 4.266 0.015
Une fois la synchronisation faite des , + et - apparaissent devant les noms de serveur. Le serveur précédé d’une astérisque () est celui utilisé, ceux précédés d’un moins (-) sont actuellement éliminés par l’algorithme de choix des serveurs, ceux précédés d’un plus (+) sont des candidats potentiels à la synchronisation et ceux précédés d’un espace sont soit inaccessibles, soit trop éloignés.
Une synchronisation correcte implique une valeur de « delay » et de « offset » non nulle, et de « jitter » inférieure à 100
Resynchroniser
sudo service ntp stop sudo ntpd -gq sudo service ntp start
timedatectl status |grep NTP
NTP enabled: yes NTP synchronized: yes
chronyc tracking chronyc sources chronyc sourcestats
/lib/systemd/system/systemd-timesyncd.service.d/wsl.conf
# Enable timesyncd on WSL machines # so WSL clock is synced on resume from suspend of the host. [Unit] ConditionVirtualization= ConditionVirtualization=|!container ConditionVirtualization=|wsl
apt-get install adjtimex
Avant de faire une manip
adjtimex -u -l=/var/log/clocks.log
Oracle recommande de changer le “clock source” à tsc pour les VM Linux x86-64.
# cat /sys/devices/system/clocksource/clocksource0/available_clocksource xen tsc acpi_pm
If the tsc clock source is available, then set tsc as the current clock source.
echo "tsc" > /sys/devices/system/clocksource/clocksource0/current_clocksource
Using any text editor, append the clocksource directive to the GRUB_CMDLINE_LINUX line in the /etc/default/grub file to retain this clock source setting even after a reboot.
/etc/default/grub
GRUB_CMDLINE_LINUX="rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never clocksource=tsc"
faketime 2016-01-01 gpg --list-keys
Voir aussi : https://coreos.com/os/docs/latest/configuring-date-and-timezone.html
/var/lib/ntp/ntp.conf.dhcp
ps -ef |grep ntp
ntp 9777 1 0 08:04 ? 00:00:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 108:113
rm /var/lib/ntp/ntp.conf.dhcp systemctl restart ntp
ou sur Redhat
rm /var/lib/dhclient/chrony.servers.eth0 systemctl restart chronyd.service
ntpdate -u pool.ntp.org
Arrêt du service (pour libérer le socket réseau UDP) puis
ntpdate -u pool.ntp.org
http://superuser.com/questions/639202/updating-time-ntpdate3108-the-ntp-socket-is-in-use-exiting ntptrace
ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met
# systemctl status systemd-timesyncd
● 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: inactive (dead)
Condition: start condition failed at Fri 2019-10-11 11:37:16 CEST; 5min ago
└─ ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met
Docs: man:systemd-timesyncd.service(8)
/lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf
[Unit] # do not run timesyncd if we have another NTP daemon installed #ConditionFileIsExecutable=!/usr/sbin/VBoxService
systemctl daemon-reload systemctl restart systemd-timesyncd