NTP Client Synchronized

In my scheduler I want to only run my script after the clock is synced with NTP server since it depends on the clock being accurate. I could just add a delay but if there is say a temporary Internet outage that will not help.

Is there a way to do this?

while NTP NOT SYNCED: { sleep(30s) }
/system script run run_script_after_synced

[/system ntp client get status] returns “synchronized” when the client is synchronized.
(assuming the ntp package is installed)

When not, maybe you can use [/system ntp client get active-server]

@hci
Maybe You should examine ‘last-update-before’ value?
If is grater than 900s (poll-interval) it indicates that was no synchronization.

HTH,

Hello, old topic I know…
I’m in a similar position of the OP, with a script to replace NTP server every day, I wonder if this is really necessary or RouterOS is able to keep synched with the sever just adding the server once (/ntp client set server=NTPpool.org…)
Thanks!

Then don’t revive it! What is written above was for RouterOS v6.x, no longer valid for RouterOS v7.x