# how often does ntpd sync time?

## sepp

I've installed an ntpd server on my server. but I ask myself how often will the time server sync with the other servers? can I control this?

the problem I have is, that the server where ntpd does run on, does not have a permantent internet connection. so I would prefer if I could configure ntpd to sync on specific dates. is that possible?

----------

## lesourbe

take a look at cron.

tell him to run 

```
ntpdate [IP of your ntp server]
```

----------

## rongfei

You can write task into crontab and the cron will do it  for you!  :Razz: 

----------

## sepp

 *lesourbe wrote:*   

> take a look at cron.
> 
> tell him to run 
> 
> ```
> ...

 

no, I don't want my client to update. I want to know how often the ntpd server does update itself. I know how to sync my client against the server. but I want to know when and how the server syncs itself.

----------

## think4urs11

 *sepp wrote:*   

> I want to know how often the ntpd server does update itself. I know how to sync my client against the server. but I want to know when and how the server syncs itself.

 

Normally this is done dynamically by ntpd depending on accuracy of your pc clock, reachability of upstream servers, and stuff.

You can (to some extend) configure this.

Default minimum is every 64 seconds, default maximum is 1024 seconds. Possible are 16 seconds on the lower end and 36.4 hours on the upper end.

----------

## kashani

The problem you may find is that ntpd only works well when you're always on. If you were to be offline for a week and your clock sucked, it might be off as much as five minutes when you connect again. ntpd does not sync, it slowly adjusts your clock to match the master. If your clock is too far off ntpd won't fix it. It's always best to run ntpdate first so that your match the master immediately and then start ntpd to keep the clock in sync.

kashani

----------

## sepp

 *Think4UrS11 wrote:*   

> 
> 
> You can (to some extend) configure this.
> 
> Default minimum is every 64 seconds, default maximum is 1024 seconds. Possible are 16 seconds on the lower end and 36.4 hours on the upper end.

 

where and how do I configure this?

----------

## think4urs11

server line in /etc/ntp.conf, parameters minpoll/maxpoll. possible values 4 (16 sec) ... 10 (1.024 sec) ... 17 (36.4 hours == 131.072 seconds)

e.g. would set the minimum time between polls to 1.024 seconds and  maximum to 36.4 hours

```
server pool.ntp.org minpoll 10 maxpoll 17
```

----------

## sepp

so 

```
server pool.ntp.org minpoll 17 maxpoll 17
```

 would force ntpd to sync only every 36.4 hours, right?

----------

## think4urs11

not sure if both can be equal

----------

## sepp

as far as I understand I could also do the following:

do $ ntpdate -u 0.pool.ntp.org once a day

run ntpd so it only serves as an time server to the lan - without syncing itself. how can I do this? does leaving out the server lines do the job?

----------

## think4urs11

 *sepp wrote:*   

> as far as I understand I could also do the following:
> 
> do $ ntpdate -u 0.pool.ntp.org once a day
> 
> run ntpd so it only serves as an time server to the lan - without syncing itself. how can I do this? does leaving out the server lines do the job?

 

Yes for ntpdate and no for ntpd.

You must tell ntpd either to sync to upstream servers or to accept its own time as reference.

Only when ntpd believes that its time is correct it will be useable as server to other more downstream clients or give out time information to peer servers.

Search for ntp.conf parameter fudge.

----------

## sepp

this should do it, right?

```

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 1

```

----------

## think4urs11

yes but you shouldn't use stratum 1. 5 is enough.

It doesn't make a difference to your clients - if the best they can get is a stratum-5 thats fine for them but it is easier to maintain a correct time on your server if its stratum is lower than the one of public ntp server (which normally have stratum 1-3, maybe 4).

you can check with ntpq -np. If the line with 127.127.1.0 starts with a '*' ntp uses it as reference and is synced to it.

----------

## sepp

 *Think4UrS11 wrote:*   

> yes but you shouldn't use stratum 1. 5 is enough.

 

in theory you are right. but windows xp clients think, that they are a super OS so they claim to be stratum 2. so you can't sync a xp client against anything else except stratum 1. (see: http://support.microsoft.com/kb/314054/EN-US/)

----------

## tgh

Most NTP configuration guides will tell you to fudge the local clock as stratum 10 (or thereabouts).  That gets it low enough so that no sane NTP client will prefer it over better clocks, unless that client has no other choice.

 *sepp wrote:*   

> in theory you are right. but windows xp clients think, that they are a super OS so they claim to be stratum 2. so you can't sync a xp client against anything else except stratum 1. (see: http://support.microsoft.com/kb/314054/EN-US/)

 

Where does it say that on that link?  WinXP clients in a domain will, by default, sync against the central domain servers.  

The (somewhat old now) issue is that Window's SNTP client in the older versions (Windows 2000) would advertise itself as a stratum 2 server, no matter what stratum it was sync'd from. The time service in Windows 2003 is better behaved (and closer to a "real" NTP implementation) and no longer advertises itself falsely as stratum 2 all the time.   Windows XP also seems to use the newer not-so-SNTP code.

(All of this is discussed regularly in the comp.protocols.time.ntp newsgroup.)

----------

## think4urs11

 *sepp wrote:*   

>  *Think4UrS11 wrote:*   yes but you shouldn't use stratum 1. 5 is enough. 
> 
> in theory you are right. but windows xp clients think, that they are a super OS so they claim to be stratum 2. so you can't sync a xp client against anything else except stratum 1. (see: http://support.microsoft.com/kb/314054/EN-US/)

 

Maybe its just me but my XP clients _can_ sync against a stratum 4 server in my LAN without any issues.

Maybe in your special case you could use chrony to sync the time. Chrony can e.g. be configured in a way to sync against a ntp server only when an internet connection is established already.

----------

