# ntpd exits after a few days

## relkai

Hi,

since "upgrading" my server hardware to a Pokini Z550 (a great little piece of hardware), I've got some problems with the NTP daemon.

After running about two days without any problems, the ntpd process just exists with the following output in /var/log/messages:

```
Nov 21 20:58:56 cheffe ntpd_intres[3873]: parent died before we finished, exiting
```

Here is my /etc/ntp.conf:

```
# NOTES:

# DHCP clients can append or replace NTP configuration files.

# You should consult your DHCP client documentation about its

# default behaviour and how to change it.

# Name of the servers ntpd should sync with

# Please respect the access policy as stated by the responsible person.

#server         ntp.example.tld         iburst

# Common pool for random people

#server pool.ntp.org

# German Stratum 2 servers

server stratum2-4.ntp.techfak.uni-bielefeld.de

server ntp1.theremailer.net

server ntp1.de

server stratum2-3.ntp.techfak.uni-bielefeld.de

server time2.one4vision.de

# Pools for Gentoo users

server 0.gentoo.pool.ntp.org

server 1.gentoo.pool.ntp.org

server 2.gentoo.pool.ntp.org

server 3.gentoo.pool.ntp.org

##

# A list of available servers can be found here:

# http://www.pool.ntp.org/

# http://www.pool.ntp.org/#use

# A good way to get servers for your machine is:

# netselect -s 3 pool.ntp.org

##

# you should not need to modify the following paths

driftfile       /var/lib/ntp/ntp.drift

#server ntplocal.example.com prefer

#server timeserver.example.org

# Warning: Using default NTP settings will leave your NTP

# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)

# from accessing the NTP server, uncomment:

#restrict default ignore

# To deny other machines from changing the

# configuration but allow localhost:

restrict default nomodify nopeer

restrict 127.0.0.1

# To allow machines within your network to synchronize

# their clocks with your server, but ensure they are

# not allowed to configure the server or used as peers

# to synchronize against, uncomment this line.

#

#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap
```

Unfortunately without ntpd my system time drifts away very quickly (about 30 minutes within 12 hours) - I don't know why the system time isn't reliable at all, but this wouldn't be a problem if ntpd would be running.

Because I also use this server as a MythTV backend the wrong time is very bad, because my scheduled recordings start and stop at the wrong time.

Could someone please point me in the right direction?

Thanks,

relkai

----------

## relkai

I just realized that in case of ntpd exiting (it just happened again), the system time suddenly is 5 or more minutes behind the real time.

Also there was a /etc/adjtime with a quite high offset value:

```
3.479655 1321616424 0.000000

1321616424

LOCAL
```

I just wrote a script which runs every 5 minutes as a cron job to "solve" this problem the quick and dirty way:

```
#!/bin/bash

if [ ! $(pidof ntpd) ]; then

        /usr/bin/sntp -s 0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org

        /etc/init.d/ntpd restart

        echo "$(date): Restarted" >> /var/log/ntpd-restart.log

        if [ -f /etc/adjtime ]; then

                rm /etc/adjtime

        fi

fi

exit 0
```

Of course I'm not really satisfied with the current workaround because it's.....well.....just a workaround.  :Wink: 

If someone has a real solution to my problem I would really appreciate it.

----------

## mokia

I made a funny discovery.

stratum2-4.ntp.techfak.uni-bielefeld.de and stratum2-3.ntp.techfak.uni-bielefeld.de made no response to ping 

ntp1.theremailer.net and ntp1.de  seems to hang the ping command sometimes 

(flooded or trafic limit)

And time2.one4vision.de seems now be definitly flooded.  

The gentoo ntp-s seems to be OK. exept 0

-[edit]-------------

Sory. I think it is my local problem.  :Sad:  I get very bad pings from everywhere... exept gentoo ntp-s   :Shocked:  WTH?

----------

## relkai

Thanks for your test, mokia.

The stratum2-* servers are indeed not pingable, but I think it's just a firewall blocking ICMP traffic because NTP works just fine.

Regarding the other servers - I made a ping test and didn't see any hickups...maybe I was just lucky.

At least the output of ntpq seems to be okay with good response times to each server:

```
     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

+stratum2-4.NTP. 129.70.130.71    2 u  255  256  377   21.617    0.818  25.384

+formularfetisch 129.69.1.153     2 u  249  256  377   24.251   -0.548   4.089

+mail.annohostin 192.53.103.104   2 u   10  256  377   20.317   -0.425   8.627

*stratum2-3.NTP. 129.70.130.71    2 u   36  256  377   20.931    1.666   7.186

+darkstar.sanet. 212.82.32.15     2 u   27  256  377   22.529   -1.860   1.856

+draco.fivemile. 131.188.3.220    2 u  264  256  377   20.959   -1.418  10.309

+svr02.teleport- 73.120.242.92    2 u  252  256  377   25.408   -1.832   8.462

-static.78-47-24 192.53.103.104   2 u   13  256  377   35.848    4.909  14.760

+sinister.wzw.tu 129.69.1.153     2 u   22  256  377   26.593   -1.478   3.551
```

Because I already had this problem while using only the default pools which are still present in my config (*.gentoo.pool.ntp.org), I don't think the servers are responsible for this behavior.

Is it possible that it has something to do with CPU scaling (cpufrequtils with ondemand governor) which scales each core from 2GHz down to 800 MHz?

I did also read somewhere that this is a known bahavior for virtual machines and could possibly solved by changing the kernel parameter for the timer frequency (mine is set to 300Hz).

To be honest I don't fully understand the meaning of this parameter and just set it to a compromise value.

----------

## mokia

I remember that i had also problems with ntp, so i changed to htpdate. 

Its not so exact as ntp, but (insert search website here) is always available.

And if you didnt need a "us" exact standard time, its still a good solution.

----------

## relkai

Sounds interesting but if I understand it correctly, it just sets the time to the fetched value.

It's missing the "soft" adjustment of ntpd. Because my system time is VERY unreliable, this could cause some other problems because the system time suddenly jumps to another time (modification time of files in the future, interrupted emerges, closing OpenVPN connections, ...).

Therefore I would like to stick to ntpd if possible...if I'm not able to solve the current problems, I will consider using htpdate, of course.

----------

