Community discussions

MikroTik App
 
hci
Long time Member
Long time Member
Topic Author
Posts: 674
Joined: Fri May 28, 2004 5:10 pm

NTP Client Synchronized

Thu Mar 22, 2018 5:54 pm

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
 
pe1chl
Forum Guru
Forum Guru
Posts: 10200
Joined: Mon Jun 08, 2015 12:09 pm

Re: NTP Client Synchronized

Thu Mar 22, 2018 6:10 pm

[/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]
 
ditonet
Forum Veteran
Forum Veteran
Posts: 835
Joined: Mon Oct 19, 2009 12:52 am
Location: Europe/Poland/Konstancin-Jeziorna
Contact:

Re: NTP Client Synchronized

Thu Mar 22, 2018 7:16 pm

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

HTH,
 
S8T8
Frequent Visitor
Frequent Visitor
Posts: 81
Joined: Thu Sep 15, 2022 7:15 pm

Re: NTP Client Synchronized

Thu Jul 20, 2023 10:09 pm

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!
 
pe1chl
Forum Guru
Forum Guru
Posts: 10200
Joined: Mon Jun 08, 2015 12:09 pm

Re: NTP Client Synchronized

Thu Jul 20, 2023 11:04 pm

Hello, old topic I know...
Then don't revive it! What is written above was for RouterOS v6.x, no longer valid for RouterOS v7.x

Who is online

Users browsing this forum: Marc1963 and 13 guests