7591 questions

9029 answers

14584 comments

11836 members

0 votes
1,569 views 5 comments
by
How to synchronize time via time server with crontabs or by script?

1 Answer

0 votes
by

Hi,

You can use the ntpclient command to synchronize time with an NTP server. For example, to synchronise time once:

ntpclient -s -p 123 -h 0.europe.pool.ntp.org

To synchronize time at a one hour (3600 seconds) interval:

ntpclient -i 3600 -D -p 123 -h 0.europe.pool.ntp.org

Execute ntpclient --help for more options or lookup possible options here.

Best answer
by

Hello,

Can I ask you something by the way?

Port 123 udp is probably blocked by my ISP, but I can synchronise time manually on the other port for example by command ntpclient -s -p 1239 -h 0.europe.pool.ntp.org. I'd like to customize settings in time synchronisation section to set and save a different port for ntp service (default is 123?). 

How can it be done permanently (automatically after every reboot) ?

Tom

by

You can change the default port in the /etc/config/ntpclient file.

You can use these commands to do so:

uci set ntpclient.@ntpserver[0].port='1239'
uci commit

Reboot the router for the changes to take effect.

by
Hello,

Thank you for pointing this simple solution.

It works as it should.

Thanks again.

Tom
by
No problem! Glad I could help.
by
How long it takes syncronization procedure at each cycle and what will happend if NTP server is not answering to its request?

What is best practice settings for NTP client on RUT955? We have bad experiency with default settings, like clock is shifting between 20 min and 1 hour at every 24 hours if syncronization cycle is 3600 sec and sim card goes at disconnected state or lose signal.