View previous topic :: View next topic |
Author |
Message |
YTW n00b
Joined: 30 Aug 2016 Posts: 65 Location: Taiwan
|
Posted: Thu Sep 01, 2016 2:25 pm Post subject: [SOLVED]Adjust both hwclock and date |
|
|
Both hwclock and date are the same
But both of them are incorrect time.
What should I do for updating them correctly via network instead of manually setting.
(I don't want to set them referring to my watch by hand because the unit of second must be wrong.)
Last edited by YTW on Fri Sep 02, 2016 11:23 am; edited 1 time in total |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30954 Location: here
|
Posted: Thu Sep 01, 2016 2:28 pm Post subject: Re: Adjust both hwclock and date |
|
|
YTW wrote: | What should I do for updating them correctly via network instead of manually setting. |
Install and configure ntp _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
YTW n00b
Joined: 30 Aug 2016 Posts: 65 Location: Taiwan
|
Posted: Thu Sep 01, 2016 3:32 pm Post subject: |
|
|
2 following questions:p
I only added these two lines in the default /etc/ntp.conf
Code: | server 127.127.1.0
fudge 127.127.1.0 stratum 10 |
then
ntpd -g -c /etc/ntp.conf
rc-service ntpd start
Now hwclock still is not correct but date is correct.
Then I use hwclock --systohc for synchronizing.
1) What will happen to system time when ntpd starting?
2) According to config file, if my laptop doesn't connect to network, what will it be set for? |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30954 Location: here
|
Posted: Thu Sep 01, 2016 4:06 pm Post subject: |
|
|
YTW wrote: | ntpd -g -c /etc/ntp.conf
rc-service ntpd start |
ntpd is for create an ntp server, I think you need only configure ntp-client. _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
YTW n00b
Joined: 30 Aug 2016 Posts: 65 Location: Taiwan
|
Posted: Thu Sep 01, 2016 4:51 pm Post subject: |
|
|
yes. I think you are right.
I already rc-update del ntp default and rc-update add ntp-client default.
So if network is connected and service didn't start at boot, I can Code: | ntpdate pool.ntp.org | for updating? |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30954 Location: here
|
Posted: Thu Sep 01, 2016 7:25 pm Post subject: |
|
|
YTW wrote: | So if network is connected and service didn't start at boot, I can Code: | ntpdate pool.ntp.org | for updating? |
Yes, or try to restart service
Code: | # /etc/init.d/ntp-client restart |
_________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Thu Sep 01, 2016 7:48 pm Post subject: |
|
|
My config is fairly typical I think:
http://bpaste.net/show/1d2ac9a0dbdb
I have a stratum 1 ntp server in my house, based on gps. So that's the 192.168.1.2 line. You'll want to take that out. |
|
Back to top |
|
|
YTW n00b
Joined: 30 Aug 2016 Posts: 65 Location: Taiwan
|
Posted: Fri Sep 02, 2016 7:35 am Post subject: |
|
|
1clue wrote: | the 192.168.1.2 line. You'll want to take that out. |
Does this mean your server synchronize time with gps instead of gentoo ntp pool? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54300 Location: 56N 3W
|
Posted: Fri Sep 02, 2016 8:04 am Post subject: |
|
|
YTW,
Yes.
GPS is an atomic time standard. When your GPS receiver works out where you are it also has to work out when you are too.
It solves four simultainious equations to get latitude, longditude' altitude and time.
It actually gets two solutions, one near the surface of the earth and one out in space.
With a fixed GPS receiver, its possible to average the position in space, so that the only unknown is time.
That gets you a very good time standard.
The down side with my GPS atomic time standard is that its on a Raspberry Pi, which has ethernet over USB, so the jitter could be better.
You get your very own stratum 1 atomic time standard. NTP pools are usually stratum 3. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
cwr Veteran
Joined: 17 Dec 2005 Posts: 1969
|
Posted: Fri Sep 02, 2016 10:59 am Post subject: |
|
|
I use an ntp.conf of:
Code: |
# Name of the servers ntpd should sync with
server 0.uk.pool.ntp.org
server 1.uk.pool.ntp.org
server 2.uk.pool.ntp.org
server 3.uk.pool.ntp.org
# you should not need to modify the following paths
driftfile /var/lib/ntp/ntp.drift
# To deny other machines from changing the
# configuration but allow localhost:
restrict default nomodify nopeer
restrict 127.0.0.1
|
I don't keep the ntp daemon running constantly, since I'm often offline, but
running 'ntpd -q ; hwclock --systohc' keeps the clock sufficiently accurate.
(I also avoid writing the system clock to the hardware clock on shutdown.)
Will |
|
Back to top |
|
|
YTW n00b
Joined: 30 Aug 2016 Posts: 65 Location: Taiwan
|
Posted: Fri Sep 02, 2016 11:23 am Post subject: |
|
|
I got it!
Thank you all for suggestion and knowledge. |
|
Back to top |
|
|
depontius Advocate
Joined: 05 May 2004 Posts: 3509
|
Posted: Fri Sep 02, 2016 1:52 pm Post subject: |
|
|
NeddySeagoon wrote: |
Yes.
...
The down side with my GPS atomic time standard is that its on a Raspberry Pi,
|
This sounds like fun.
What is your hardware/software?
Does it have to be all the way outside, or is an attic mount sufficient?
I guess the other thing is that you now know very accurately where your home is. _________________ .sigs waste space and bandwidth |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Fri Sep 02, 2016 3:49 pm Post subject: |
|
|
It seems that Neddy probably read the same website I did. Mine's on a pi b+.
I have:
- pi b+ v2 (single-core)
- adafruit ultimate gps v3
- an external antenna (must have!)
There's also a board specifically designed to mount the gps onto a pi, I'd recommend that, and a case.
AFAIK all the pi's share the usb/nic issue so jitter doesn't really improve with a better pi. I'd research that to be sure and then:
- If it's true then go with the cheapest pi
- If it's not then get the one with better throughput.
I'm about USD $100 all in, including shipping. This is significantly cheaper than a commercially-available gps-based stratum 1 time server.
I'm using Raspbian with the gui stripped out. I used this site for instructions, and links from it http://www.satsignal.eu/ntp/Raspberry-Pi-quickstart.html
The down side is every time you do a dist upgrade you pretty much have to fix it. The instructions are a little different every time, and a pi is not a rocket for compiling so that's a drag.
The up side is it's like a mini vacation from my real job. Which actually requires a good time source.
I had a pi b+ running Gentoo, but the 'disk' went wonky and I haven't put it back up. About all it ever did was run gentoo, no real tasks.
I've thought about pulling the gps chip out and putting it in my router box (http://www.supermicro.com/products/motherboard/atom/x10/a1srm-ln7f-2758.cfm) where it could be a really high quality time server, but haven't gotten around to it. This box is also running VMs and a router so I don't really want all my eggs in one basket.
Edit: About the antenna. I did this without the antenna first, the GPS got a link about 80% of the time when outdoors, about 60% of the time when in a window with good sky access. The battery on the gps is a must for fast booting. When I got the antenna I could put the pi anywhere I want as long as the antenna is outside, and I always get a fast link to the gps. |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Fri Sep 02, 2016 3:55 pm Post subject: |
|
|
When you do this for a pi, you need to google <year> raspberry pi gps time server because there's always something new out there, and somebody upstream probably changed something important.
If you're not using raspbian you may want to try googling your distro too.
The instructions are often dummied down so you may have to reverse engineer what they were saying. The link I gave is fairly straightforward and has been actually maintained pretty well over multiple dist-upgrades. |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Fri Sep 02, 2016 4:02 pm Post subject: |
|
|
Actually if you're trying to do this then you might want to look at other boards which don't have the ethernet-over-slow-usb problem. The idea behind a time server is that constant conditions make more accurate timekeeping, so in my opinion that means having a box that does nothing but keep time, in a constant-temperature environment, is a good thing.
I haven't really done that research, but I've done a little bit of research for my next micro-linux box. Something like a minnowboard (which I think is discontinued) would be alright. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54300 Location: 56N 3W
|
Posted: Fri Sep 02, 2016 7:03 pm Post subject: |
|
|
depontius,
My system is an early Pi B (one of the first 10,000). The guide I followed has a warning notice now.
I have the internal patch antenna too.
During commissioning, it worked well on a South facing window sill. The GPS satellites are in inclined orbits that mean they never get overhead from the UK.
Until you have the GPS ephemeris, transmitted from the gps satellites, the poor wee thing doesn't know where the satellites are. That's important, because the CA code is transmitted spread spectrum and the centre frequency is affected by a variable doppler shift related to the satellites motion, that needs to be compensated for.
Acquiring the first satellite is hard. It may take hours. Once that's done, the system knows about all the rest.
If you are impatient, you can provide the ephemeris and sync time to network time.
You can't get the P-code. Its encrypted. For a GPS ntp server the CA code is good enough.
I use the patch antenna indoors, sort of, its in my garage, that has a corrugated fibre (asbestos?) roof that is covered in moss.
It claims it can see 13 satellites, which I don't believe. That's over half the constellation. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Fri Sep 02, 2016 7:30 pm Post subject: |
|
|
YTW wrote: | 1clue wrote: | the 192.168.1.2 line. You'll want to take that out. |
Does this mean your server synchronize time with gps instead of gentoo ntp pool? |
This isn't my config for the time server, it's my config for other boxes on my net.
Regarding the time server box:
In order to start ntp correctly, you need pool.ntp.org servers to be in your list. The gps doesn't give a unique time, but it's like 70 years unique, or something like that.
So you need to have another line with 'prefer' at the end, and then 2 lines for the gps receiver itself. I can post that file if there's interest, but you can get it from the link I showed.
So the system with the gps boots, and since there is no real-time clock on the pi it starts the ntp process and hooks up to the preferred (or maybe some other) ntp server for a few minutes, and then when the pps from the gps chip has been deemed stable it enhances the currently referenced ntp server with the pps signal. At that point you go from stratum 2 or 3 or whatever you were to stratum 1. |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Fri Sep 02, 2016 7:35 pm Post subject: |
|
|
In addition, ntp sometimes decides that a server it was using is no longer stable for some reason, like the route is down or there's a lot of latency to the server. My other boxes sometimes decide that a different time server is better for a little while. |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Fri Sep 02, 2016 11:47 pm Post subject: |
|
|
This thread reminds me of something I've wanted to do for a while: I've got no shortage of rooted Android phones with GPS receivers built in. I've looked a few times in the past for some way to coax them into acting as an NTP/GPS local network server, but never found anything of the sort... |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Sat Sep 03, 2016 1:47 am Post subject: |
|
|
I've seen ntp for rooted android phones, but I question the value of a stratum 1 time server over wifi. I'm not sure the latency is low enough to work out. |
|
Back to top |
|
|
cwr Veteran
Joined: 17 Dec 2005 Posts: 1969
|
Posted: Sat Sep 03, 2016 1:50 pm Post subject: |
|
|
I used an Adafruit Ultimate GPS breakout board with an Atmel AVR 382p
(the basic Arduino CPU) to build a time server. It supplied time via the
serial port, but with an Arduino Ethernet I suppose it could have supplied
it via Ethernet.
I tried one of the long-wave time signal stations, but for some reason could
never get a reliable signal lock.
Will |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54300 Location: 56N 3W
|
Posted: Sat Sep 03, 2016 6:52 pm Post subject: |
|
|
cwr,
A long time ago approx 40 years? a magazine called Wireless World published a series of articles describing a radio time code clock all made with TTL logic.
I still have the articles somewhere, along with my implementation of that clock.
I don't think I ever got the RF (60kHz) bit right, since I could never detect even the slow code. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
|