You are not logged in.

#1 2010-03-26 09:53:58

dammannj
Member
Registered: 2009-01-28
Posts: 44

state of ntp

Hello,

I have some trouble with ntp.
I have two machines on my LAN, I tried running both with openntpd. I want to sync both to an external time server.
However, one of the machines doesn't keep time accurately. Yesterday, it was 3 minutes behind the other, which showed the correct time. I then tried the 'official' ntp daemon, and used ntpdate to adjust the clock.
Now you could tell me to just keep using ntp instead of openntpd - but I have some problems with this as well: while not listed as a dependency, ntp requires libdns_sd.so.1, avahi stuff - which is a lot to install just to have ntp imho.. Is that correct?

I then switched back to openntpd, to see how fast clock skew affects this system
Now the machine is 1 second fast.

From what I have read openntpd does not set the time, but slows or speeds up the clock, so that over time the machine should converge to the right time. But on this system it does not seem to work.

Anyone have any suggestions which program to use?

Anyone experienced this problem with openntpd as well?

Can I get rid of the avahi dependence of ntp by recompiling with some flags?

Thanks in advance
Julian

Offline

#2 2010-03-26 10:18:32

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: state of ntp

Hi dammannj,

although others might tell you that this is not the best idea, my experience is that the simplest solution for time synchronisation is to create a cronjob as the root user that calls:

/usr/bin/ntpdate <your_favourite_ntp_server>

As far as I can tell, this works perfectly and I have no need to set up an ntp daemon.

Kind regards,
jamesbond007.

Offline

#3 2010-03-26 10:52:40

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: state of ntp

ntpdate is deprecated. If you really want that functionality, use "ntpd -q" or whatever the corresponding option is. As jamesbond007 already mentioned, that is not recommended because the time will not be continuous on your system. I've also read somewhere that doing that every hour creates load issues for ntp servers, so use a larger interval if you do.

I had problems with openntpd before because I start the network daemon in the background in rc.conf (@network). If openntpd comes up before the network does, it might fail to run correctly. I solved this by adding the following to /etc/rc.local:

(sleep 300 && /etc/rc.d/openntpd start) &

Since then I've had no problems with time on my system.

*edit*
Obviously I removed the openntpd daemon from the array in rc.conf.

Last edited by Xyne (2010-03-26 10:54:06)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#4 2010-03-26 11:18:56

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: state of ntp

Thank you for your answers. From what I understand ntpd -q wouldn't be as accurate as running ntpd continuously, and the system time would not adjust over time but instantly, which is not desirable imo.

I start all daemons without the @ , e.g. not backgrounded.

Some more information: the system with the problems is a small router. It is powered 24/7, but disconnected from the internet every 12 hours by my provider. It then reconnects. The other system (the one on which openntpd does work), is rebooted at least once per day (e.g. my workstation which is off while I'm not at home, sleep, or don't need a computer).
Might this be the problem?

Offline

#5 2010-03-26 12:38:59

Rorschach
Member
From: Ankh-Morpork
Registered: 2008-11-07
Posts: 143

Re: state of ntp

Don't use ntpdate or ntpd -q the problem which can occur from this can be pretty big. The time should be adjusted slowley like openntpd does and not with one hit like ntpdate does, just because all your timestamps will mess up. This can cause problems with some applications, so really never do this!

As Xyne correctly said: if openntpd doesn't have a network connection when it starts it will not work, also if the network connection will be available later on. openntpd will be just a idling process doing nothing. Check with "sudo grep ntpd /var/log/daemon.log" if openntpd is adjusting your time. If not it's probably not correctly running. How do you start your network? If you use networkmanager, you have to start openntpd as dispatcher-daemon.

Offline

#6 2010-03-26 12:55:02

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: state of ntp

dammannj wrote:

ntp requires libdns_sd.so.1, avahi stuff

Recompile it. I have ntp, and dont have either of those.

Offline

#7 2010-03-26 13:42:49

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: state of ntp

@Rorschach:
I use the standard network daemon and the adsl daemon provided by rp-pppoe.
I'll try to have openntpd restarted on reconnection ( /etc/ppp/ip-{up,down}.d/ scripts )

@brebs
Thanks, I'll recompile if the above doesn't work (I like the compactness of openntpd)

Offline

#8 2010-03-28 10:00:14

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: state of ntp

I have tested the first solution for the last 2 days, and till now the clocks are in sync.

Just for reference, my solution for using openntpd with dial up adsl:

/etc/ppp/ip-up.d/01-openntpd.sh

#!/bin/bash
/etc/rc.d/openntpd start

/etc/ppp/ip-down.d/01-openntpd.sh

#!/bin/bash
/etc/rc.d/openntpd stop

Offline

#9 2010-03-28 10:51:13

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: state of ntp

I use to start openntpd whenever my adsl successfully connected, using this script

#!/bin/bash
#
# Connect to the Internet.

sudo /etc/rc.d/adsl start && sudo /etc/rc.d/openntpd restart

Likewise opentpd should stop before the adsl disconnects.

#!/bin/bash
#
# Disconnect from the Internet.

sudo /etc/rc.d/openntpd stop
sudo /etc/rc.d/adsl stop

These scripts are bound to two openbox shortcut keys here.


To know or not to know ...
... the questions remain forever.

Offline

#10 2010-03-29 08:21:12

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: state of ntp

@bernarcher:
There is one problem with your solution *if* your provider terminates the connection after some time (in my case every 12h). I have configured ppp to be always on, that is not on demand. The daemon won't be restarted automatically, neither will your script be executed in such a case.

Offline

#11 2010-03-29 09:07:00

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: state of ntp

@dammannj:
Sure, but my provider doesn't do so, fortunately. But it would be easy to implement some timer process in this case, possibly using the "at" command or something the like.

Last edited by bernarcher (2010-03-29 09:07:50)


To know or not to know ...
... the questions remain forever.

Offline

#12 2010-03-29 19:53:26

fettouhi
Member
Registered: 2007-05-07
Posts: 745

Re: state of ntp

I'm a bit confused by this thread. If I want to update the time on machine through the internet via ntp what is the best method then? I simply want something that automatically handles the daylight time savings when they occur. Currently I'm using ntpd running at boot via rc.conf. Is that good enough? Is ntpdate necessary to run at boot because in my case it fails every time at boot and I'm running it before ntpd. What is deprecated ntpd or openntpd? The wiki says openntpd is deprecated.

Offline

#13 2010-03-30 09:17:22

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: state of ntp

@ntp:
I think it is not about right or wrong, but about choice. ntpdate sets the time once, then quits. ntpd is a deamon which keeps synchronizing over time. Maybe in your case just using ntpd works, then you should not need ntpdate. As to openntpd, I prefer using it because it follows the kiss principle.

@timezone: I think this is handled not by ntp, but by setting TIMEZONE in /etc/rc.conf according to your timezone. Daylight time savings should occur independent of ntp usage.
rc.sysinit uses the TIMEZONE setting to copy /usr/share/zoneinfo/$TIMEZONE to /etc/localtime

Offline

#14 2010-03-30 10:50:27

fettouhi
Member
Registered: 2007-05-07
Posts: 745

Re: state of ntp

For some reason the daylight time savings has never worked for me on Arch Linux and I've set everything in rc.conf. After I switched to ntp then daylight time worked.

Offline

#15 2010-03-30 15:56:32

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: state of ntp

To make matters more complicated, ntpdate is itself deprecated upstream in favor of "ntpd -q". I've got a FR open requesting that we change our initscripts to keep up with that change.

Offline

#16 2010-03-30 16:36:26

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: state of ntp

Where's this idea that openntpd isn't or won't be supported coming from? It works. It does exactly what it's supposed to do. The version for Linux is a port of the primary tree, just like it's always been.

Offline

Board footer

Powered by FluxBB