UCI ntpclient configuration doesn't clear old configuration etc


When I do UCI ntpclient configuration using code configuration, configuration file /etc/config/ntpclient still keep old configuration ( i.e. not clean the old configuration ). Please see below:

root@freewave-ib:/root# uci show ntpclient

This doesn't happen to UCI network configuration by using code. ( UCI ntpclient code configuration is very
similar to UCI network code configuration).

Is there any solution on this?



uci commit


Without knowing the code you use it is hard to tell anything. But my guess is that you're using a mere uci add ntpserver to add a new section, without deleting old sections.

Try something like this:

# loop as long as we can delete an existing section of type ntpserver
while uci -q delete ntpclient.@ntpserver[0]; do

# add a new ntpserver section and set values
uci add ntpclient ntpserver
uci set ntpclient.@ntpserver[0].port=215
uci set ntpclient.@ntpserver[0].hostname=

I found out the reason. Please ignore the issue.


Thanks a lot! I have already found the reason, which has nothing to do with openwrt uci.




In my job, I have to port NTP code to openwrt environment, do you know how to convert this code

to openwrt uci equivalent:

"ntpdate -p8 any_net_work_time_server"

Linux ntpdate command option -p just mean "samples".

Thanks in advance!



busybox version of ntp, not the "real" ntp, correct?

Personally, if you've got enough space in your build, I'd install the "real" ntpd, especially if time is important enough to you to request 8 samples from your reference time server.

I don't see a clear equivalent of the -pN option to ntpdate in the busybox-supplied version.

jeff@office:~$ sudo busybox ntpd --help
BusyBox v1.29.2 () multi-call binary.

Usage: ntpd [-dnqNwl -I IFACE] [-S PROG] [-p PEER]...

NTP client/server

	-d	Verbose (may be repeated)
	-n	Do not daemonize
	-q	Quit after clock is set
	-N	Run at high priority
	-w	Do not set time (only query peers), implies -n
	-S PROG	Run PROG after stepping time, stratum change, and every 11 mins
	-p PEER	Obtain time from PEER (may be repeated)
	-l	Also run as server on port 123
	-I IFACE Bind server to IFACE, implies -l



The only thing is that my supervisor doesn't allow me to use busybox.

He would like me to use UCI NTP configuration directly or through UBUS.

He even restrict me just use C/C++ to invoke UBUS's ubs_connect(), ubus_lookup_id(),

ubus_invoke() etc. UBUS code. However, if you can tell me how to use

UCI command line directly, I can figure out how to translate to code.

The major thing that I am not clear is:

how to specify "ntp .. server"'s server.

Is the server equivalent to:

UCI's ntpclient.@ntpclient[0].interface


UCI's ntpclient.@ntpserver[0], {1], {2], {3].

I thought that it seems the ntpclient.@ntpclient[0].interface because it also allow user

to specify options count and samples. ( Can the interface representing a server. From

network viewpoint, that is true because server use one interface IP address as it's

IP addrss.)

However, Linux ntpdate allows you to specify more than one server in ntpdate command line.

so I am confusing!

The other thing bothers me is that if it means ntpclient.@ntpserver[], then how do you invoke

them in the code to simulate the "ntpdate ... server1 server2 ..."

Many thanks,


The config files can be "edited" through UCI -- https://openwrt.org/docs/guide-user/base-system/uci

The times I've worked with it have taken some poking about to get the right order of commands and creating/selecting lists of things, but it is a very functional interface to the config.

https://openwrt.org/docs/guide-user/advanced/ntp_configuration may help with the variables, along with looking at the config that LuCI generates.


What's the difference between busybox ntp and "real" ntp?

My supervisor would like to use UCI/UBUS compatible code in openwrt. The "ntpdate -p" command was used in embedded Linux, not openwrt Linux.

Also, is busybox implementation based on UCI/Ubus? The reason that I am asking this question is because busybox seems exist beyond openwrt and

we will only use openwrt UCI/Ubus compatible implementation in openwrt environment ( according to my suoervisor ).

Many thanks,


"Real" NTP to me is that of or based on the reference implementation of NTPv4. The package ntpd for OpenWrt uses reference-implementation sources.


busybox implements probably something like 90% if the executables on OpenWrt. In general, the busybox "applets" are functional for the basic purposes needed, but usually lacking in functionality past that.


In my experience the ntp implementation in busybox is functional, but not as accurate or robust as that of the reference implementation, nor as flexible. For most people looking for synchronization to a couple tenths of a second, it is generally sufficient.

I have no idea what

means in your situation. Both the "real" and the busybox implementation can be configured with UCI and started with procd. How ubus fits into your requirements, you'll have to get clarification from your supervisor as, for most applications, ubus is completely behind the scenes or doesn't come into play at all.


Do you know which script or file during system boot/initialization invoke /etc/config/ntpclient?

I don't see /etc/init.d nor /usr/sbin/ntpd-hotplug invoking /etc/config/ntpclient.

/etc/config/ntpclient is openwrt ntp configuration file, why no script/file invoke it?



fgrep and find are tools that can often answer these questions.

root@OpenWrt:/etc# fgrep -ri ntp /etc

quickly reveals


among other references.

root@OpenWrt:/etc# find /rom -iname '*ntp*'

is fast and effective when you can guess the name of the file.


Many thanks,

I believe that /usr/sbin/ntpd is not busybox ( openwrt) ntpd. It reads configuration file from /etc/init.d/ntp.conf.

( If you type /usr/sbin/ntpd, the manual page is going to mention the configuration file as /etc/init.d/ntp.conf.)

However, openwrt UCI's configuration file is located at /etc/config/network/ntpclient

By the way, what's the difference between /etc/init.d/syntpd and busybox's ntpd ( I believe that it is located in /bin )

Many thanks!



Past that one is a start-up script and one is an executable, you can examine the various start-up scripts and see which executables they run and how any needed configuration files are created. I believe the start-up script for the busybox version of ntpd is sysntpd