J’ai un kernel ou la config CONFIG_RTC_SYSTOHC est activée. Si j’ai bien compris, ce la permet de mettre à jour l’heure RTC toutes les 11 minutes avec l’heure système si ce dernier est bien synchronisé. Or j’ai ntp qui tourne sur ma debian et quand le fais ntpq -p , j’obtiens:
remote refid st t when poll reach delay offset jitter
==============================================================================
0.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.002
1.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.002
2.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.002
3.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.002
-ntp.ulyssis.stu 193.190.230.65 2 u 287 1024 377 20.776 -2.177 0.506
+84-199-86-248.i 192.168.0.100 2 u 31 1024 337 22.725 0.431 0.537
-srcf-ntp.stanfo 171.64.7.73 2 u 252 1024 377 142.315 1.248 1.366
-ntp.devrandom.b 244.220.219.218 2 u 403 1024 377 15.591 -0.554 0.429
+neel.ch .GPS. 1 u 127 1024 377 18.055 1.869 1.002
*tock.ntp.infoma .GPS. 1 u 434 1024 377 15.750 1.413 0.941
Il y a une ligne commençant par ‹ * › donc pour moi, l’heure système est bien synchronisée.
J’initialise ma RTC avec une « mauvaise heure » : hwclock --set --date « 2020-12-17 8:55:26.021053+00:00 »
puis je vérifie régulièrement que ma RTC va bien se synchroniser avec l’heure système en moins de 11minutes:
root@sr-imx6:~# date; hwclock -r
Thu 17 Dec 2020 11:02:40 AM UTC
2020-12-17 08:55:36.115268+00:00
root@sr-imx6:~# date; hwclock -r
Thu 17 Dec 2020 11:08:46 AM UTC
2020-12-17 09:01:42.279962+00:00
root@sr-imx6:~# date; hwclock -r
Thu 17 Dec 2020 11:15:16 AM UTC
2020-12-17 09:08:12.844868+00:00
root@sr-imx6:~# date; hwclock -r
Thu 17 Dec 2020 11:19:29 AM UTC
2020-12-17 09:12:25.394854+00:00
Comme vous pouvez le constater, ça n’est absolument pas le cas.
Pourquoi???
En effet.
J’ai une question, est-ce que ce besoin répond à un problème particulier ?
Parce que l’heure de l’horloge système est suffisemment précise et, si tu as un client NTP, ce n’est pas forcément utile d’avoir une horloge matérielle à la bonne heure (par exemple, le Raspberry Pi n’a pas l’horloge matérielle et fonctionne très bien).
Sinon, je suppose que si tu lances une commande du style hwclock --systohc, ça fonctionne et tout va bien, tu pourrais choisir le lancer cette commande à intervales réguliers à l’aide de cron.
timedatectl
Local time: sam. 2020-12-19 15:32:38 CET
Universal time: sam. 2020-12-19 14:32:38 UTC
RTC time: sam. 2020-12-19 14:32:38
Time zone: Europe/Paris (CET, +0100)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
root@debian:/boot# grep RTC config-5.9.0-5-amd64
CONFIG_HPET_EMULATE_RTC=y
# CONFIG_PM_TRACE_RTC is not set
CONFIG_RTC_LIB=y
CONFIG_RTC_MC146818_LIB=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_SYSTOHC_DEVICE="rtc0"
# CONFIG_RTC_DEBUG is not set
CONFIG_RTC_NVMEM=y
# RTC interfaces
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
# CONFIG_RTC_DRV_TEST is not set
# I2C RTC drivers
# CONFIG_RTC_DRV_ABB5ZES3 is not set
# CONFIG_RTC_DRV_ABEOZ9 is not set
# CONFIG_RTC_DRV_ABX80X is not set
# CONFIG_RTC_DRV_DS1307 is not set
# CONFIG_RTC_DRV_DS1374 is not set
# CONFIG_RTC_DRV_DS1672 is not set
# CONFIG_RTC_DRV_MAX6900 is not set
# CONFIG_RTC_DRV_RS5C372 is not set
# CONFIG_RTC_DRV_ISL1208 is not set
# CONFIG_RTC_DRV_ISL12022 is not set
# CONFIG_RTC_DRV_X1205 is not set
# CONFIG_RTC_DRV_PCF8523 is not set
# CONFIG_RTC_DRV_PCF85063 is not set
# CONFIG_RTC_DRV_PCF85363 is not set
# CONFIG_RTC_DRV_PCF8563 is not set
# CONFIG_RTC_DRV_PCF8583 is not set
# CONFIG_RTC_DRV_M41T80 is not set
# CONFIG_RTC_DRV_BQ32K is not set
# CONFIG_RTC_DRV_S35390A is not set
# CONFIG_RTC_DRV_FM3130 is not set
# CONFIG_RTC_DRV_RX8010 is not set
# CONFIG_RTC_DRV_RX8581 is not set
# CONFIG_RTC_DRV_RX8025 is not set
# CONFIG_RTC_DRV_EM3027 is not set
# CONFIG_RTC_DRV_RV3028 is not set
# CONFIG_RTC_DRV_RV8803 is not set
# CONFIG_RTC_DRV_SD3078 is not set
# SPI RTC drivers
# CONFIG_RTC_DRV_M41T93 is not set
# CONFIG_RTC_DRV_M41T94 is not set
# CONFIG_RTC_DRV_DS1302 is not set
# CONFIG_RTC_DRV_DS1305 is not set
# CONFIG_RTC_DRV_DS1343 is not set
# CONFIG_RTC_DRV_DS1347 is not set
# CONFIG_RTC_DRV_DS1390 is not set
# CONFIG_RTC_DRV_MAX6916 is not set
# CONFIG_RTC_DRV_R9701 is not set
# CONFIG_RTC_DRV_RX4581 is not set
# CONFIG_RTC_DRV_RX6110 is not set
# CONFIG_RTC_DRV_RS5C348 is not set
# CONFIG_RTC_DRV_MAX6902 is not set
# CONFIG_RTC_DRV_PCF2123 is not set
# CONFIG_RTC_DRV_MCP795 is not set
CONFIG_RTC_I2C_AND_SPI=y
# SPI and I2C RTC drivers
# CONFIG_RTC_DRV_DS3232 is not set
# CONFIG_RTC_DRV_PCF2127 is not set
# CONFIG_RTC_DRV_RV3029C2 is not set
# Platform RTC drivers
CONFIG_RTC_DRV_CMOS=y
# CONFIG_RTC_DRV_DS1286 is not set
# CONFIG_RTC_DRV_DS1511 is not set
# CONFIG_RTC_DRV_DS1553 is not set
# CONFIG_RTC_DRV_DS1685_FAMILY is not set
# CONFIG_RTC_DRV_DS1742 is not set
# CONFIG_RTC_DRV_DS2404 is not set
# CONFIG_RTC_DRV_STK17TA8 is not set
# CONFIG_RTC_DRV_M48T86 is not set
# CONFIG_RTC_DRV_M48T35 is not set
# CONFIG_RTC_DRV_M48T59 is not set
# CONFIG_RTC_DRV_MSM6242 is not set
# CONFIG_RTC_DRV_BQ4802 is not set
# CONFIG_RTC_DRV_RP5C01 is not set
# CONFIG_RTC_DRV_V3020 is not set
# on-CPU RTC drivers
# CONFIG_RTC_DRV_FTRTC010 is not set
# HID Sensor RTC drivers
# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set
CONFIG_INTEL_SMARTCONNECT=m
root@debian:/boot#
Oui, mon système n’est pas forcément connecté à internet et sachant qu’au démarrage, l’heure système est initialisé avec l’heure matériel (RTC), j’ai besoin que les évènements (logs) soit correctement daté donc que l’heure matériel soit le plus exact possible.
C’est justement ce qu’il faut éviter à tout prix, car il faut le faire uniquement si l’heure système est bien synchronisé avec un serveur NTP. C’est le role de la config kernel CONFIG_RTC_SYSTOHC=y . Elle est là pour ça.
timedatectl
Local time: Mon 2020-12-21 09:38:13 UTC
Universal time: Mon 2020-12-21 09:38:13 UTC
RTC time: Mon 2020-12-21 07:31:49
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: inactive
RTC in local TZ: no
C’est bizarre que timedatectl me dit que le service NTP est inactif alors que ntpd est bien lancé:
systemctl status ntp
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-12-10 13:16:41 UTC; 1 weeks 3 days ago
Docs: man:ntpd(8)
Main PID: 710 (ntpd)
Tasks: 2 (limit: 466)
Memory: 1.3M
CGroup: /system.slice/ntp.service
└─710 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 106:114
Bonjour grandtoubad,
Merci de t’interesser à mon sujet.
Citation
ce sont deux fonctions indépendantes
Je ne sais pas de quelles fonctions tu me parles. J’ai ntp activé par défaut sur mon système et je ne vois pas pourquoi ça fonctionnerait moins bien.
config RTC_SYSTOHC
bool "Set the RTC time based on NTP synchronization"
default y
help
If you say yes here, the system time (wall clock) will be stored
in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11
minutes if userspace reports synchronized NTP status.
Citation if userspace reports synchronized NTP status
ça serait pas ça mon problème? comment savoit si l’espace utilisateur notifie bien que NTP est bien synchronisé?
Cela n’a rien de bizarre tu ne peux pas utiliser deux démons de synchronisation temporelle en même temps. Soit c’est systemd-timesyncd, soit c’est ntpd (ou chronyd). D’ailleurs sir ntpd est installé systemd-timesyncd est désactivé automatiquement.
Dans ton cas c’est ntpd.
Il y a un début d’explication (pas sûr d’avoir tout compris) à ce que tu observes ici : https://unix.stackexchange.com/questions/186394/rtc-time-synchronization-not-working-config-rtc-systohc
Si ta machine n’est pas serveur de temps pour le réseau, tu peux supprimer ntpd et utiliser systemd-timesyncd (avec le quel je n’observe pas ce problème).