Time Syncronization

From MiOS
Revision as of 16:17, 8 May 2012 by Cj man (Talk | contribs)

Jump to: navigation, search

The Vera units use by default rdate to synchronize the time.
Rdate is a client program which uses the Time protocol and does one time query and synchronization. Rdate servers are running the Time service protocol on port 37 which conforms to RFC 868. Clients can use either TCP or UDP.
The Time Protocol (RFC858) is not related or compatible with Network Time Protocol (RFC 958) used by ntpclient/ntpd/openntp.



  • Vera hardware
  • Root acces to your OpenWRT


Gain ssh access to your Vera (root) and use the password that is provided on the bottom of your vera2. More info on how to can be found here:[1]

Time Servers are listening on port 37 and Network Time Servers on 123.
Note: In order for you Vera unit to successfully syncronize its time you have to allow connections from it to the time servers on port 37 for rdate and port 123 for ntpclient if you install it.

Check if Vera can sync with a Time Server :

rdate -p server

The -p switch prints the date and time from the server.

Set the time from a Time Server:

rdate -l -s server

The -l switch allows for logging results to Syslog, -s sets the system time.

There is no worldwide list of Time servers available. Many, but not all, Network Time Protocol (NTP) servers also serve Time on port 37. There is a list of NTP servers here [2]

The National Institute of Standards and Technology (United States Gov't) offers about a dozen Time servers to the public. Their server list is available here [3]

Here is a list of working servers (at this moment):


To test on your Vera unit which servers are working, log in by ssh and then create a new file called timeservers.txt in /tmp with this command :

touch /tmp/timeservers.txt

Then edit it and copy the servers from the list using vim, and then run this command at least 5 times :

while read server; do echo -n "Server $server :"; rdate -p $server && echo "OK" || echo "FAILED"; done < /tmp/timeservers.txt

After that compare the results and pick the servers that only display OK, these will be the most reliable, and then add them to the list here /etc/config/timeserver .

To sync the time use the following command :

ash -x /usr/bin/sync_time.sh

Creating a local time server

If you want to create a local time servers you can use xinetd and you can read more about it here [4]

Once all the settings have been made you need to restart xinetd by using this command :

/etc/init.d/xinetd reload

Installing the NTP client

Run the following commands to install the NTP client by ssh:

opkg update
opkg install ntpclient
for i in 0 1 2 3; do ntpclient -c 1 -p 123 -h $i.openwrt.pool.ntp.org; done
/etc/init.d/ntpclient restart

To check if the ntp client is running use this command:

ps fax | grep ntp

If you see this message then you've successfully installed the NTP client:

4188 root      1068 S    /usr/sbin/ntpclient -i 600 -s -l -D -p 123 -h 0.openwrt.pool.ntp.org
14454 root      1672 S    grep ntp

To edit the ntp.conf file you can use the vim editor:

vim /etc/ntp.conf

To view the current entries in your ntp.conf type:

cat /etc/ntp.conf

Note: Please remember to keep the same format of the file when you edit it.

Personal tools