What's new

Disable ntp?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Mars2035

Occasional Visitor
Hi,
I am using Asus RT-AC56u (FW 380.62) at the mom I dont need the ntp service, because I set actual datetime manually.
How can I disable it persistently? BTW which function does exist in router os to show actual state of a service?

Thanks and regards.
 
I am using Asus RT-AC56u (FW 380.62) at the mom I dont need the ntp service, because I set actual datetime manually.
How can I disable it persistently?
You could try setting the NTP server (Administration > System > NTP Server) to a bogus value.

BTW which function does exist in router os to show actual state of a service?
There isn't one.
 
I did this, but that doesnt really stops the service, every 30sec there is a syslog entry from ntp.
When the datetime is set manually (e.g. python script) on services-start event it seems it will be overwritten by another process back to original FW time.
Would be a "killall ntp" at first on services-start a solution?
 
Would be a "killall ntp" at first on services-start a solution?
I don't know, try it and find out. But I suspect the watchdog process will restart it. There are some parts of the routers functionality that require an accurate time source that a lot of effort has been directed to making sure the NTP client is always running.

But why use a python script anyway? If it's because you want a super-accurate time source search these forums for @kvic' ntp replacement, that might help.
 
I did this, but that doesnt really stops the service, every 30sec there is a syslog entry from ntp.
When the datetime is set manually (e.g. python script) on services-start event it seems it will be overwritten by another process back to original FW time.
Would be a "killall ntp" at first on services-start a solution?
If you aren't using the TrendMicro stuff (Adaptive QoS, etc), the ability to disable the NTP service is available on my fork.
 
Mostly this router runs without any connection by WAN, but to have a reliable time source I always connect a RTC clock via USB and run that PY script to have the actual time.
To leave ntp server address empty and let run the service is also fine for me.
@john: I am new in this forum, where is y fork located?
 
How can I disable it persistently?
In a pinch, you could try this to prevent the Asus' NTP CLIENT from running:

/jffs/scripts/init-start
Code:
#!/bin/sh

if [ -f /jffs/clock-saved ]; then

  # restore the clock
  CLOCK="$(/usr/bin/head /jffs/clock-saved)" && SECONDS=${CLOCK#*.} && SECONDS=${SECONDS#*0} && /bin/date -u -s ${CLOCK%.*}.$(($SECONDS + 48))

  # disable the Asus' NTP CLIENT
  if [ $? -eq 0 ]; then
    /usr/bin/killall ntpclient
    /bin/mount -o bind /dev/null /usr/sbin/ntpclient
    /usr/sbin/nvram set ntp_ready=1
    /usr/sbin/nvram unset ntp_server0
    /usr/sbin/nvram unset ntp_server1
    /usr/sbin/nvram unset ntp_server_tried
  fi

fi


/jffs/scripts/services-stop
Code:
#!/bin/sh

# save clock
/bin/date -u +%Y%m%d%H%M.%S > /jffs/clock-saved
 
Last edited:
Don't prevent the ntp client from starting. Some services in the firmware will rely on a flag getting set in nvram by ntpclient before considering the current clock to be accurate.

If you really must, kill it only after it has done its initial task of setting the clock and the nvram flag.
 
Would be a "killall ntp" at first on services-start a solution?

Put it at the end (add some sleep before it if needed..). Will work like a charm and save you a big chunk of RAM. Then run your python script to source time from your external RTC.

You may also try asat's script above..
 
I was successfull to stop ntp by calling killall ntp at the end of services-start. I dont see it anymore in syslog.

...kill it only after it has done its initial task of setting the clock and the nvram flag.
When is this exactly? How can I find out when these events happen according to syslog?

According to Fritz script
...
if [ -f /jffs/clock-saved ]; then
# restore the clock
CLOCK="$(/usr/bin/head /jffs/clock-saved)" && SECONDS=${CLOCK#*.} && SECONDS=${SECONDS#*0} && /bin/date -u -s ${CLOCK%.*}.$(($SECONDS + 48))
...
Am I right when I would set this global CLOCK value by the USB RTC device it would be to late because the RTC is available not until post-mount/services-start runs?

...
/usr/sbin/nvram set ntp_ready=1
/usr/sbin/nvram unset ntp_server0
/usr/sbin/nvram unset ntp_server1
/usr/sbin/nvram unset ntp_server_tried
...
Does this descrease the lifetime of the router in general? I dont run the router on 24/7 base it will be startup/shutdown upto 2 times /day only.

Thank you for your advice.
 
When is this exactly? How can I find out when these events happen according to syslog?

There's no clean way to do so, short of launching a script at boot that will do a loop, check every minute if time has been set, and kill ntp and exit if it did. Personally I don't see any point in killing the ntp client.

Setting an nvram value has no impact on the flash, since it only gets written to it on a commit. I don't recommend unsetting the stored ntp servers, it will only cause trouble down the road, and there is no reason to do so.
 
You manually set the time every time the router restarts/crashes/locks/loses power?

Seems rather silly to me.
 
Am I right when I would set this global CLOCK value by the USB RTC device it would be to late because the RTC is available not until post-mount/services-start runs?
My script requires that you set the clock manually, at some point. Example:
Code:
/bin/date -s 201701201258.00

Then when you reboot the router, it will save the current time at shutdown in a JFFS file, and when the router starts up again it will restore the clock to the time of the last shutdown plus 48 seconds.

Your idea for a USB RTC is good. However, if you have the skills for that, it's also possible to connect a GPS module to the USB port. Configure the GPS module to restrict its output to report only the current time. It will show this:

/bin/head /dev/ttyUSB0
Code:
$GPZDA,205423.00,20,01,2017,00,00*63
$GPZDA,205424.00,20,01,2017,00,00*64
$GPZDA,205425.00,20,01,2017,00,00*65
$GPZDA,205426.00,20,01,2017,00,00*66
$GPZDA,205427.00,20,01,2017,00,00*67
$GPZDA,205428.00,20,01,2017,00,00*68
 
That could be also a solution. Thanks again.
I will try it when I solve the problem with USB 3 hub during cold start the router.
It seems that the hub dont let the router mounting all harddisks reliable. But I will maybe open another thread.
 

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top