Cubieboard – setting time zone and NTP on ubuntu

Cubieboard – setting time zone and NTP on ubuntu

I have just bought cubieboard and installed lubuntu and I want to have synchronized time with NTP server. NTP is a TCP/IP protocol for synchronising time over a network – Network Time Protocol.

This post describes:

  • Setting the timezone
  • Configuring NTP for clock synchronization

Setting the timezone

To check the time and timezone:

date
more /etc/timezone

To configure timezone execute: 

sudo dpkg-reconfigure tzdata

 

 

 

Configuring NTP for clock synchronization

I used NTP server in Europe to synchronize time via the NTP protocol.
You can check the server for you in ntp.org or just use the main NTP server: ntp.ubuntu.com.

sudo ntpdate europe.pool.ntp.org

Main ntp servers for continents are listed bellow. If you click on the link, you will see NTP servers for countries.:

Continuously adjusts clock

 

1. Continuously adjusts clock using cron

To execute ntpdate in cron just create a file /etc/cron.daily/ntpdate with 775 and text /etc/cron.daily/ntpdate.

2. Continuously adjusts clock by ntpd daemon

Use ntpd if you want to have daemon that calculates the drift of your system clock and continuously adjusts it, so there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory.

Install ntpd:

sudo apt-get install ntp

Configure NTP servers in config file: /etc/ntp.conf

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server 0.europe.pool.ntp.org
server 1.europe.pool.ntp.org
server 2.europe.pool.ntp.org
server 3.europe.pool.ntp.org

I made a simple one line command that configures default ubuntu NTP servers to the europe.pool.ntp.org.

sudo sed -i "s#ubuntu.pool.ntp.org#europe.pool.ntp.org#" /etc/ntp.conf
# After changing the config file you have to reload the ntpd
sudo service ntp reload

You can see the status of the ntpdby ntpq command.

# sudo ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+betelgeuse.retr 193.62.22.74     2 u   37   64  377   26.840   -4.780   0.391
+193.170.62.252  131.188.3.220    2 u   49   64  377    3.520   -5.018   0.387
-ntp-ext.cosng.n 146.213.3.181    2 u   45   64  377   46.128   -6.622   0.850
-ntp.luna.nl     193.79.237.14    2 u   43   64  377   22.228   -2.890   0.286
*golem.canonical 193.79.237.14    2 u   33   64  377   29.205   -4.021   0.465

Although, I’m not sure what that status means. 😉