Raspberry Pi – NTP Client setup

Some of this may be automatic, but knowing how to make the manual changes for specific NTP servers would be a good thing. This is the first step that you will need to take in order for the next installments of this series to work correctly.

By default, debian will come up in UTC. To make it reflect the time where you are –

Option 1 – sudo raspi-config, select change_timezone

Option 2 – sudo dpkg-reconfigure tzdata, Select the right country/timezone

Once you have used either one of these options, you should see something similar to this on the screen –

Current default time zone: ‘US/Central’
Local time is now: Mon Feb 4 22:47:46 CST 2013.
Universal Time is now: Tue Feb 5 04:47:46 UTC 2013.

Another way of check the settings you just changed is to do a cat /etc/localtime. Most of the file will look like random information. At the very bottom, you will see some similar to CST6CDT which shows you the timezone that your RPi is current set for.

Using the date command will show you the current date/time that your Raspberry Pi is currently using.

pi@raspberrypi:~$ date
Sun Feb 24 14:38:41 CST 2013

What we have gone through is the foundation for what you will need later when we start working with a GPS receiver to make your Raspberry Pi a proper network NTP Time Server. There are some troubleshooting skills that you will want to have for now and for later.

You will want to become familiar with ntpq as it will give you a command line equivalent of a management console. I would suggest using ntpq with the -n option to disable DNS resolution so that you can see the actual ip addresses being used. Once you get the ntpq> prompt, type pe (short for peers) and you should see the following –

ntpq> pe
remote refid st t when poll reach delay offset jitter
==============================================================================
+199.241.31.96 164.244.221.197 2 u 47 64 377 144.936 -45.430 24.697
-24.124.0.251 128.206.12.130 3 u 14 64 377 106.325 14.020 9.222
*199.7.177.206 64.147.116.229 2 u 15 64 377 206.455 23.064 9.259
+204.2.134.164 129.250.35.251 3 u 12 64 377 136.437 -27.934 13.104

The first character on each line tells you a little more. The asterisk says that the server on that line is the one that is being used at the NTP time source at this point. The lines with a plus sign indicates that these are candidates for use as a time server.

One file that you should be familiar with even if you don’t need to make changes in it occasionally is /etc/ntp.conf. Here are the lines from that file from my RPi showing the systems that it is configured setup to look at for NTP service –

# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool:
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst

These are good to get started with. When we get to the next installment of the NTP series, you will be making some changes. In the next installment, I will walk through the setup of the GPS Receiver from the folks at ADAFRUIT that will be needed to get access to the time clock information that is contained in the GPS data stream coming from the network of GPS satellites currently in orbit.

To see more of my posts about the Raspberry Pi, please go to http://www.ronnutter.com/category/raspberry-pi/

Send to Kindle
This entry was posted in Blog Entries, Raspberry Pi and tagged . Bookmark the permalink.