Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to synchronize my (stand-alone) computer clock to an atomic clock when I'm online. If that happened automatically when I go online it would be magic, but I could live with doing it by hand.
I know you've heard this question millions of times, I've seen it - I searched the forum, but all I found was the information to use ntpd / ntpdate (I already got that far) and read the xntp-doc. Frankly, reading that documentation is a bit like becoming a world class surgeon in order to pull a splinter out of my thumb. I tried, but I simply don't get any of it. I've tried (as root):
ntpdate 204.34.198.40 (and a number of other IPs found by googling)
and all that ever gets me is 'no server suitable for synchronization found'
Now I'm sure I'm just missing something which is probably simple, but the people who wrote the documentation were SO above giving even the smallest of examples. Or if they did it seems to be well-hidden under loads of information I neither need nor understand.
So can anyone give me a rundown for idiots in simple terms about how to do it?
You don't want to use ntp-update, you want to use ntpd, because ntpd slowly corrects your clock is it doesn't screw anything up (like cause you to have file access times that are before current time that that stuff).
Here is an example config file for ntpd:
Code:
restrict 127.0.0.1
fudge 127.127.1.0 stratum 3
server <server1>
server <server2>
server <server3>
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
Save this as ntp.conf in /etc and run ntpd and it should read it and whenever it can contact those servers (any time you are on-line) it'll poll them to keep your clock right and calculate how much your clock drifts and what not. Also, replace the <server1>, <server2>, <server3> with servers from this list: http://www.eecis.udel.edu/~mills/ntp/clock2a.html
Before starting ntpd, it's a good idea to run ntpdate to set the clock to the correct time.
Better yet, you might have a file in /etc/ntp/ called step-tickers. Put a server in there, and anytime the computer starts ntpd, it will contact that server to get the correct time.
Originally posted by jtshaw You don't want to use ntp-update, you want to use ntpd, because ntpd slowly corrects your clock is it doesn't screw anything up (like cause you to have file access times that are before current time that that stuff).
Here is an example config file for ntpd:
Code:
restrict 127.0.0.1
fudge 127.127.1.0 stratum 3
server <server1>
server <server2>
server <server3>
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
Save this as ntp.conf in /etc and run ntpd and it should read it and whenever it can contact those servers (any time you are on-line) it'll poll them to keep your clock right and calculate how much your clock drifts and what not. Also, replace the <server1>, <server2>, <server3> with servers from this list: http://www.eecis.udel.edu/~mills/ntp/clock2a.html
Ok, thanks for the quick reply. I'm running SuSE 9.0, and Yast2 comes with a module which sets up such servers in ntp.conf; I had tried that before, but there are some differences between my file and the sample you posted. To be precise, here's the content of my file:
-----
server 127.127.1.0
fudge 127.127.1.0 stratum 10
server ntp.globe.cz
server 203.21.37.18
server 195.13.23.5
server 209.87.233.53
server 217.127.2.161
driftfile /var/lib/ntp/drift/ntp.drift
logfile /var/log/ntp
-----
What does the 'restrict' line do, and what does the different digit after stratum mean?
I changed the system time to silly values, and as it is now there is no sign of ntpd setting the clock to anything. How can I test things?
Some more: I seem to be missing an argument. Apparently ntpd tries to do something with the servers, but it doesn't work. Here's the content of the logfile:
4 Feb 20:49:50 ntpd[10369]: signal_no_reset: signal 17 had flags 4000000
4 Feb 20:52:57 xntpd[10425]: signal_no_reset: signal 17 had flags 4000000
4 Feb 20:52:59 xntpd[10425]: server returns a permission denied error
4 Feb 20:52:59 xntpd[10425]: signal_no_reset: signal 14 had flags 4000000
4 Feb 20:53:09 xntpd[10425]: ntpd exiting on signal 15
4 Feb 20:53:09 xntpd[10424]: ntpd exiting on signal 15
4 Feb 20:53:09 ntpd[10368]: ntpd exiting on signal 15
4 Feb 21:52:56 ntpd[12490]: signal_no_reset: signal 17 had flags 4000000
4 Feb 08:54:42 ntpd[12489]: sendto(81.95.96.3): Invalid argument
4 Feb 08:54:51 ntpd[12489]: sendto(203.21.37.18): Invalid argument
4 Feb 08:54:51 ntpd[12489]: sendto(209.87.233.53): Invalid argument
4 Feb 08:54:52 ntpd[12489]: sendto(217.127.2.161): Invalid argument
4 Feb 08:54:55 ntpd[12489]: sendto(195.13.23.5): Invalid argument
4 Feb 08:31:50 ntpd[12489]: time set 0.000000 s
4 Feb 08:31:50 ntpd[12489]: synchronisation lost
ntpd will run as a server so people can connect to you and get the time from you. The restrict line restricts ntpd to the local host preventing it from being bound to the external IP. I am not sure if it is really neccesary or not. The number after stratum doesn't matter, so long as you don't change it to 1 or 2.
To test to see if it is working type ntpq -p. It should output something like this:
Code:
remote refid st t when poll reach delay offset jitter
==============================================================================
+ns2.anycast.cac Tick.UH.EDU 2 u 332 1024 377 35.768 -2.740 1.931
+ourconcord.net NAVOBS1.MIT.EDU 2 u 334 1024 377 70.054 15.538 2.334
*ntp-0.gw.uiuc.e truechimer.cso. 2 u 238 1024 377 45.247 -3.063 2.024
I have edited the list of servers to only include those which offer open access without notice and include Germany in their service area. I must have another error in my setup, as ntpq -p only gives me 'ntpq: read: Connection refused'
I bet I first have to initialize something or other... but what? And_how?
Maybe it's got something to do with the automatic start of the ntp daemon. Yast advises me not to set it to start automatically during boot, and I have obliged, as it says that the network connection must be started first; and I don't start the connection automatically during startup but only on demand.
I don't know enough about Linux daemons yet to tell whether it is actually running, just because the command gives back a result different from 'command not found'.
Funny, I haven't changed anything since yesterday, but now ntpq -p gives me a more useful output:
Code:
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 4 64 1 0.000 0.000 0.008
eloise.lost-oas 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
fartein.ifi.uio 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
c-573470d5.06-2 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
kryten.alphazed 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
ntp1.belbone.be 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
But the numbers look so much cleaner than the ones in the example posted above that I still suspect there's something wrong. So I disabled the firewall which comes with SuSE 9.0, and here's the output after that:
Code:
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) LOCAL(0) 10 l 55 64 17 0.000 0.000 0.008
eloise.lost-oas 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
fartein.ifi.uio chronos.cru.fr 2 u 42 64 1 120.836 -103.91 0.008
c-573470d5.06-2 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
kryten.alphazed 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
ntp1.belbone.be 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
Apparently the fartein server is now responding; is that enough? And I cannot find any setting in the firewall setup dialogue which might be responsible for the problem (like excepting a port or something). I'm not sure I should leave the firewall off entirely just for that
Is ntpd supposed to check and set the clock automatically or is there still something I have to do by hand?
No IP tables, it mostly seems to block everything, though you can checkmark things you want your computer to act as server for. None of these are marked, as I don't operate any kind of server.
Trying it again right now (having made no changes) I get a timeout. Weird.
I don't get it. Maybe I should just set my clock by hand.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.