What's new

NTP Daemon for ASUSWRT/Merlin

  • 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!

Can I please ask one last thing? If you are running default logs setting, meaning I haven't played with where the logs are kept, what is the location of this syslog? Thanks sorry for being a newbie pain in the butt....lol
Hi @skeal, Since you have /jffs enabled, the log file should be in a file called syslog.log and another called syslog.log-1. If /jffs is not enabled, I believe the location is /tmp. I see the same syslog.log and syslog.log-1 files there.

Code:
admin@RT-AC88U:/tmp/home/root# ps | grep log
  444 admin     1396 S    /sbin/syslogd -m 0 -S -O /tmp/syslog.log -s 256 -l 5
 
Hi @skeal, Since you have /jffs enabled, the log file should be in a file called syslog.log and another called syslog.log-1. If /jffs is not enabled, I believe the location is /tmp. I see the same syslog.log and syslog.log-1 files there.

Code:
admin@RT-AC88U:/tmp/home/root# ps | grep log
  444 admin     1396 S    /sbin/syslogd -m 0 -S -O /tmp/syslog.log -s 256 -l 5

Thank you muchly!! Done and working!! Thanks again.
 
Thank you from me too. Logs now going to /tmp/aswrt-crond.log
 
As I am a noob, can I ask where would the best place for the log to go? Could I set it up to write to my NAS, for example?

I realise I am moving a bit off topic...
 
Last edited:
RE: "NTP server" entry on Admin page

Pls leave it as-is. Your router's firmware need it on startup to initialise its system clock. The firmware does it through its so called "ntp" service.

Once the system clock is initialised, when Entware-ng starts, the script, /opt/etc/init.d/S77ntpd-custom will kill the firmware's "ntp" service and launch the true NTP daemon provided in the package of this thread.

When I reboot ntpd does not start for some reason. Everything else starts.
I can get ntpd going by executing this command.
Code:
/opt/etc/init.d/S77ntpd-custom start
then stats work and I get results when I type:
Code:
/jffs/bin/ntpq -p
Can anyone help?
 
Last edited:
When I reboot ntpd does not start for some reason. Everything else starts.
I can get ntpd going by executing this command.
Code:
/opt/etc/init.d/S77ntpd-custom start
then stats work and I get results when I type:
Code:
/jffs/bin/ntpq -p
Can anyone help?

'cos I'm lazy :p...and life is too short etc. I have the following at the end of

/jffs/scripts/init-start
Code:
<snip>

# Should be sufficient to cover physical BOOT process?
# Normally 3 mins is ample, ....
logger -st "($(basename $0))" $$ "Paused for 4 mins....."
sleep 240

# Check Entware apps...ntpd is usually still in 'dead' state?
if [ ! -z "$(/opt/etc/init.d/rc.unslung check | grep dead)" ];then
 logger -st "($(basename $0))" $$ "**Warning Restarting 'dead' Entware apps....."
 /opt/etc/init.d/rc.unslung restart
fi
exit 0

Code:
Aug  1 01:00:40 (post-mount): 1525 Adding NTPD statistics display to Tools TAB .....
Apr 19 23:10:37 ntpd[1651]: ntpd 4.2.8p4@1.3265 Tue Nov  3 14:54:58 UTC 2015 (3): Starting
Apr 19 23:10:37 ntpd[1651]: ntpd 4.2.8p4@1.3265 Tue Nov  3 14:54:58 UTC 2015 (3): Starting
Apr 19 23:10:37 ntpd[1651]: Command line: ntpd -c /jffs/etc/ntp.conf
Apr 19 23:10:37 ntpd[1651]: Command line: ntpd -c /jffs/etc/ntp.conf
Apr 19 23:10:37 ntpd[1658]: proto: precision = 1.972 usec (-19)
Apr 19 23:10:37 ntpd[1658]: Listen normally on 0 lo 127.0.0.1:123
Apr 19 23:10:37 ntpd[1658]: Listen normally on 1 br0 10.88.8.1:123
Apr 19 23:10:37 ntpd[1658]: Listening on routing socket on fd #18 for interface updates
Apr 19 23:10:38 admin: Started ntpd from .
Apr 19 23:13:37 ntpd[1658]: error waiting on child 1659: No child processes
 
Last edited:
'cos I'm lazy :p...and life is too short etc. I have the following at the end of

/jffs/scripts/init-start
Code:
<snip>

# Should be sufficient to cover physical BOOT process?
# Normally 3 mins is ample, ....
logger -st "($(basename $0))" $$ "Paused for 4 mins....."
sleep 240

# Check Entware apps...ntpd is usually still in 'dead' state?
if [ ! -z "$(/opt/etc/init.d/rc.unslung check | grep dead)" ];then
 logger -st "($(basename $0))" $$ "**Warning Restarting 'dead' Entware apps....."
 /opt/etc/init.d/rc.unslung restart
fi
exit 0

Code:
Aug  1 01:00:40 (post-mount): 1525 Adding NTPD statistics display to Tools TAB .....
Apr 19 23:10:37 ntpd[1651]: ntpd 4.2.8p4@1.3265 Tue Nov  3 14:54:58 UTC 2015 (3): Starting
Apr 19 23:10:37 ntpd[1651]: ntpd 4.2.8p4@1.3265 Tue Nov  3 14:54:58 UTC 2015 (3): Starting
Apr 19 23:10:37 ntpd[1651]: Command line: ntpd -c /jffs/etc/ntp.conf
Apr 19 23:10:37 ntpd[1651]: Command line: ntpd -c /jffs/etc/ntp.conf
Apr 19 23:10:37 ntpd[1658]: proto: precision = 1.972 usec (-19)
Apr 19 23:10:37 ntpd[1658]: Listen normally on 0 lo 127.0.0.1:123
Apr 19 23:10:37 ntpd[1658]: Listen normally on 1 br0 10.88.8.1:123
Apr 19 23:10:37 ntpd[1658]: Listening on routing socket on fd #18 for interface updates
Apr 19 23:10:38 admin: Started ntpd from .
Apr 19 23:13:37 ntpd[1658]: error waiting on child 1659: No child processes

Thank you for your script! I'll copy it to my notepad++ and save it. Right now what I've done is just add 15 seconds to the delay of entware start script in services-start. So far everything works. I used the diagnostic commands from an earlier post and it all works. Thank you for your support.
 
atomic clocking my router and home network? From my day job, I understand how important clocking and clock references are, so this is quite intriguing as far as the possibilities go.
When my brain has the processing cycles to devote to absorbing this thread, I hope to learn if this will work with my n66u running 380.65_4. I have a feeling I'll have to finally roll up my sleeves and dig into scripts.
Cool beans.
 
First of all @kvic , thanks for your efforts and the installation guide at Github, all seems to went flawless and was up and running in a matter of minutes. No graphing data yet, but thay will probably come over time as corrections are made. Just a few questions: in the tutorial you state I should use Stratum One servers closest to me, yet in /jffs/etc/ntp.conf it says

Code:
# use a random selection of 4 public stratum 2 servers
# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers

Which ones should I use? I assume Statum One servers give more accurate results?

And second, what does the 'iburst' addition behind the server IP's do?

And last, but not least, I see

Code:
ntpd -c /jffs/etc/ntp.conf

in syslog during startup, but when run manually, it says

Code:
ASUSWRT-Merlin RT-AC68U 380.66-2 Wed May 17 03:00:05 UTC 2017
marco@RT-AC68U:/tmp/home/root# ntpd -c /jffs/etc/ntp.conf
ntpd: invalid option -- c
BusyBox v1.25.1 (2017-05-16 23:00:03 EDT) multi-call binary.

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

NTP client/server

        -d      Verbose
        -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
        -t      Trust network and server, no RFC-4330 cross-checks
        -S PROG Run PROG after stepping time, stratum change, and every 11 mins
        -p PEER Obtain time from PEER (may be repeated)
                If -p is not given, 'server HOST' lines
                from /etc/ntp.conf are used
        -l      Also run as server on port 123
        -I IFACE Bind server to IFACE, implies -l

Notice the 'ntpd: invalid option -- c'?

Seems like it doesn't read /jffs/etc/ntp.conf to use the servers I manually replaced, the ones closest to me?

Thanks in advance.
 
Last edited by a moderator:
Just a few questions: in the tutorial you state I should use Stratum One servers closest to me, yet in /jffs/etc/ntp.conf it says

Code:
# use a random selection of 4 public stratum 2 servers
# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers

Which ones should I use? I assume Statum One servers give more accurate results?

Shh..if you manage to find stratum one servers near you, by all means use them and perhaps keep them to yourself. I used to have access to stratum one servers by Apple 1ms away. Sadly now they're relocated to thousands of miles away.

And second, what does the 'iburst' addition behind the server IP's do?

You can read about ibrust here... Not important in modern days with reliable network connection.

Code:
And last, but not least, I see

[code]
ntpd -c /jffs/etc/ntp.conf

"/jffs/bin" is not in system's default search path. You shall use full path i.e.
Code:
/jffs/bin/ntpd -c /jffs/etc/ntp.conf

Otherwise, you called the busybox version of ntpd which seems being added to the FW build in the past year or so. lol
 
Shh..if you manage to find stratum one servers near you, by all means use them and perhaps keep them to yourself. I used to have access to stratum one servers by Apple 1ms away. Sadly now they're relocated to thousands of miles away.

I consider myself lucky then :rolleyes:

"/jffs/bin" is not in system's default search path. You shall use full path i.e.
Code:
/jffs/bin/ntpd -c /jffs/etc/ntp.conf

Otherwise, you called the busybox version of ntpd which seems being added to the FW build in the past year or so. lol

That explains a lot, for example why I didn't see the same error during startup. From which script is

Code:
/jffs/bin/ntpd -c /jffs/etc/ntp.conf

started while the router is booting? Thanks in advance.
 
Last edited by a moderator:
I consider myself lucky then :rolleyes:

You're indeed. Consider the chance a good stratum one server is open to public, and close to you. It's low to a large population.

Code:
/jffs/bin/ntpd -c /jffs/etc/ntp.conf

started while the router is booting? Thanks in advance?

I can't recall if a init.d script is included for ppl with Entware installed. That's one way to get it started. My preferred method.

You can also append the above line to /jffs/scripts/services-start if you don't have Entware installed.
 
kvic - thanks for your wonderfull work and awesome coding - installed and it is up and running even after reboot ... one question to the ntp.conf file - home many stratum servers should be added - only 4? or more or less? - the closest stratum is around 70 km far away uses GPS, found other stratum 1 servers but are even more far away - the local ones are close... the question shall I ping them, is it wise to use 8 servers - starting with the closest stratum and the last will be a close but not stratum server? Thanks
 
one question to the ntp.conf file - home many stratum servers should be added - only 4? or more or less?

From three to seven is recommended. ntpd will check all listed regularly to determine which three to use: one primary and two backups. The rest will be idle backups. So order in the config file isn't important. Some said 7 is ideal number and I forgot the rationale behind.

kvic - thanks for your wonderfull work and awesome coding - installed and it is up and running even after reboot ...

Next step when you have time to kill is integrating the HTML portion of the package into your FW trx file by using the Asuswrt Mod Kit in this thread. :)
 
Just wondering if anyone knows if this USB GPS will work ?
I think you'll be limited to the maximum length for USB 2.0 cable. Since your router is not up on the roof of the building. You'll need to position this GPS receiver near a window where it can receive the satellite signal.

It probably needs to support NMEA since that the most common way to interface with NTP. The Generic NMEA driver in NTP is what I've had success with. If it says u-blox anywhere it probably supports NMEA. When you plug it in, it will probably show up as a USB modem /dev/ttyACM0
 
Last edited:
I think you'll be limited to the maximum length for USB 2.0 cable. Since your router is not up on the roof of the building. You'll need to position this GPS receiver near a window where it can receive the satellite signal.

It probably needs to support NEMA since that the most common way to interface with NTP. The Generic NEMA driver in NTP is what I've had success with. If it says u-blox anywhere it probably supports NEMA. When you plug it in, it will probably show up as a USB modem /dev/ttyACM0
Yeah fortunately it is near a window, probably about 1.5m from the router but I would use a 3m extension cable to let me run it to the floor and back to the window to keep things neat, anything over 5m for USB and you get lost packets without a repeater and a repeater would probably break it totally!
It has blox in the title so may be worth a punt and a months wait at that price.

Thanks.
 
Just wondering if anyone knows if this USB GPS will work ? http://www.ebay.co.uk/itm/VK172-G-M...410048?hash=item2379afa700:g:jn0AAOSwEzxYW0kK

Otherwise can someone tell me what does work :)

Thanks.

That shall be fun. Just be aware that the ntpd binary in #1 is stripped of all junks that include tons of hardware drivers that most users don't need. So it's a slim build that fits in 900KB of RAM.

When you get one of those hardware dongle, the binary in #1 won't work for you. Ask nicely and get a custom build from Fitz perhaps. Or you can get the one from Entware-ng (which unfortunately uses 10MB RAM when I last checked years ago).
 
That shall be fun. Just be aware that the ntpd binary in #1 is stripped of all junks that include tons of hardware drivers that most users don't need. So it's a slim build that fits in 900KB of RAM.

When you get one of those hardware dongle, the binary in #1 won't work for you. Ask nicely and get a custom build from Fitz perhaps. Or you can get the one from Entware-ng (which unfortunately uses 10MB RAM when I last checked years ago).
I would but it isn't fair asking for custom builds is a bit cheeky so I will scrap the plan as it isn't really needed on a home network :)
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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