NTP comes preloaded and preconfigured as part of Raspbian. I found the only thing I had to change was my time zone, as by default it is set to UTC, which is most useless for most people on this planet.
But first a few things on ntp. First of all check if it is running and if it is able to contact any of the ntp servers in the predefined pools. Do this by issuing:
sudo ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*timeserver3.int .GPS. 1 u 24 64 1 45.420 -0.104 1.546
dns1-ha.au.syra 41.12.6.160 2 u 23 64 1 96.005 2.503 3.844
ns1.mel.bkb.net 192.189.54.33 3 u 22 64 1 32.453 2.264 2.255
ds1.zagbot.com 74.189.58.78 2 u 22 64 1 46.616 -0.014 1.141
The way these ntp servers above are picked is in accordance with the NTP server pools configured in /etc/ntp.conf
If you decide to make change to the ntp.conf file, please restart the ntp service to have these changes take effect:
/etc/init.d/ntp restart
OK, so now, how to change the local timezone? In the /etc/ directory, there is a symbolic link, called localtime, that points to the actual localised time zone (see below).
In my case I am using Melbourne, Australia (because Sydney sucks big hairy monkey balls). You can go to the /usr/share/zoneinfo/ directory and see which geographical part of the world applies to you, then drill into it, until you find the applicable timezone. Easy stuff.
You can also use tzselect to determine your timezone, but note that tzselect has nothing to do with permanently localising your timezone!!!
pi@raspberrypi /usr/bin $ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 7
Please select one of the following time zone regions.
1) Lord Howe Island 8) Queensland - most locations
2) Macquarie Island 9) Queensland - Holiday Islands
3) Tasmania - most locations 10) South Australia
4) Tasmania - King Island 11) Northern Territory
5) Victoria 12) Western Australia - most locations
6) New South Wales - most locations 13) Western Australia - Eucla area
7) New South Wales - Yancowinna
#? 5
The following information has been given:
Australia
Victoria
Therefore TZ='Australia/Melbourne' will be used.
Local time is now: Thu Nov 28 23:08:38 EST 2013.
Universal Time is now: Thu Nov 28 12:08:38 UTC 2013.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
TZ='Australia/Melbourne'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Australia/Melbourne
So the last thing to do is to link the /etc/localtime to the timezone you want:
sudo ln -sf /usr/share/zoneinfo/Australia/Melbourne /etc/localtime
To verify if it has worked, issue:
lrwxrwxrwx 1 root root 39 Nov 28 23:27 localtime -> /usr/share/zoneinfo/Australia/Melbourne
Halleee!
No comments:
Post a Comment