openwrt -time ()

 

 

/etc/init.d/sysntpd

/etc/config/system

By default busybox-ntpd runs as a client and does not serve time.

config timeserver 'ntp'
        option enable_server '1'    <---- Enable server
        list server 'stdtime.gov.hk'
        list server 'time.windows.com'

-c count => retry count
-d => daemon mode
-i => interval between updates
-p port => port to connect
-s => set clock

查看:

netstat -anu

 


 

ntpclient

The ntpclient is started via the hotplug.d subsystem upon any network interface startup

NTP (RFC-1305, RFC-4330) client

/etc/hotplug.d/iface/20-ntpclient

 

# use the first one that is responding to time requests.

config ntpserver
        option hostname 'stdtime.gov.hk'
        option port     '123'

config ntpserver
        option hostname 'time.windows.com'
        option port     '123'

config ntpdrift
        option freq     '0'

config ntpclient
        option interval 600            # 10min 一次 (default)
        option count    0              # 無限試 (default)
        option interface wan           # 只有此 interface up 時才 test

 

ntpclient:

Usage: ntpclient [-c count] [-d] [-f frequency] [-g goodness] -h hostname
        [-i interval] [-l] [-p port] [-q min_delay] [-r] [-s] [-t]

options:

 -c count     stop after count time measurements (default 0 means go forever)
 -d           print diagnostics (feature can be disabled at compile time)
 -g goodness  causes ntpclient to stop after getting a result more accurate
                   than goodness (microseconds, default 0 means go forever)
 -h hostname  (mandatory) NTP server, against which to measure system time
 -i interval  check time every interval seconds (default 600)
 -l           attempt to lock local clock to server using adjtimex(2)
 -p port      local NTP client UDP port (default 0 means "any available")
 -q min_delay minimum packet delay for transaction (default 800 microseconds)
 -r           replay analysis code based on stdin
 -s           simple clock set (implies -c 1)
 -t           trust network and server, no RFC-4330 recommended cross-checks

 ntpclient -s -h stdtime.gov.hk

 

Creative Commons license icon Creative Commons license icon