no NTP update after reboot RouterOS v7 hAP ax³

Hi all,

i would like to force an ntp update/sync directly after reboot on an hAP ax³ running RouterOS v7 with container mode. I is crucial for me the system gets the correct time immediately after reboot for my container application and logging.

As far as i understand, the ntp client syncs about every 3 hours, so after a reboot i have a wrong system time for about that time? See following log example
/IP/Cloud time sync is deactivated.

Here is an example of one of my Systems with relevant logs from yesterday, reboot and NTP update:

Feb/15/2024 12:37:58 system,error,critical router rebooted without proper shutdown, probably power outage
Feb/15/2024 14:20:10 system,critical,info ntp change time Feb/15/2024 12:38:19 => Feb/15/2024 14:20:10

Last Log entry, then reboot, i think it startet with the time of the last ntp update, maybe?

Feb/15/2024 16:43:39 dhcp,info defconf assigned 10.10.111.190 for E8:6F:38:91:24:B5 ALLNB008
Feb/15/2024 14:20:20 system,error,critical router rebooted without proper shutdown, probably power outage

…rebooted again → and again startet with the same time, then ntp update nearly three hours later:

Feb/15/2024 14:20:20 system,error,critical router rebooted without proper shutdown, probably power outage
Feb/15/2024 17:11:42 system,critical,info ntp change time Feb/15/2024 14:24:42 => Feb/15/2024 17:11:42

So an easy fix would be to force an ntp update after reboot, but i did not find a solution
Should i disable and reenable ntp via boot up script? Any recommendations would help, thanks in advance

Feb/15/2024 12:37:58 system,error,critical router rebooted without proper shutdown, probably power outage
Feb/15/2024 14:20:10 system,critical,info ntp change time Feb/15/2024 12:38:19 => Feb/15/2024 14:20:10

Appears to indicate time change happened <1 minute after reboot. 12:37:58 to 12:38:19 time change

Feb/15/2024 14:20:20 system,error,critical router rebooted without proper shutdown, probably power outage
Feb/15/2024 17:11:42 system,critical,info ntp change time Feb/15/2024 14:24:42 => Feb/15/2024 17:11:42

Seems to indicate time change happened within 4 minutes of reboot, 14:20:20 to 14:24:42 time change.

Looks like it was either

  1. powered off for quite some time
  2. The time had not been saved to flash more recently while it was running.

I think 2 is more likely. (Don’t want to keep updating flash just because time has changed)

I read this log differently:

Feb/15/2024 14:20:20 system,error,critical router rebooted without proper shutdown, probably power outage

At some time the router rebooted, at the time it booted the clock value was Feb/15/2024 14:20:20

Feb/15/2024 17:11:42 system,critical,info ntp change time Feb/15/2024 14:24:42 => Feb/15/2024 17:11:42

After some time, 4 minutes and 22 seconds after the reboot, the NTP synchronized and changed the time from 14:24:42 to 17:11:42.

That it takes 4 minutes 22 seconds (262 seconds) to synchronize the NTP (usual values are between 64 and 1024 seconds) seems to me “normal” (or rather “possible”).

The question is WHEN all this happened, since the log entry on Feb/15/2024 17:11:42 is about the actual time set to Feb/15/2024 17:11:42, the second entry happened at 17:11:42.

But the same message says that at that exact time, the clock was at 14:24:42.

The first entry says that it happened at 14:20:20m but in reality it happened 14:24:42-14:20:20=4:22 before the second one, i.e. it happened 4:22 seconds before 17:11:42, at 17:07:20.

So it is the date/time of the first log entry (the reboot one) that is “off”, the NTP is IMHO updating in a reasonable time after reboot.

… many thanks for reading my log. You are right, it only took 4 minutes what i did not realize by reading only the time at the beginning of the line…

Yes, the logging could have been clearer;

Feb/15/2024 17:11:42 system,critical,info ntp change time Feb/15/2024 14:24:42 => Feb/15/2024 17:11:42

if split in two or more lines (hypothetical and probably a bit too verbose)

Feb/15/2024 14:24:42 system,critical,info ntp detected out-of-sync on Feb/15/2024 14:24:42
Feb/15/2024 14:24:42 system,critical,info ntp change time Feb/15/2024 14:24:42 => Feb/15/2024 17:11:42
Feb/15/2024 17:11:42 system,critical,info ntp corrected time to Feb/15/2024 17:11:42

This way it would be evident that the sync happened at the “previous” time.