You are not logged in.

#1 2010-06-20 02:25:42

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

Should NTP Processes Never End?

For my NTP needs, I've installed openntpd, removed /etc/cron.hourly/adjtime, and added this line to my crontab,

* * * * * ntpd -s && hwclock -w > /dev/null 2>&1 && rm /var/lib/hwclock/adjtime

It works like a charm; however, I have noticed that the ntpd processes never seem to complete. Here's a snippet from my "ps aux" output,

root     11746  0.0  0.0  18196   468 ?        Ss   02:10   0:00 ntpd -s
ntp      11764  0.0  0.0  13984   860 ?        S    02:11   0:00 ntpd -s
root     11769  0.0  0.0  18196   344 ?        Ss   02:11   0:00 ntpd -s
ntp      11780  0.0  0.0  13984   860 ?        S    02:12   0:00 ntpd -s
root     11785  0.0  0.0  18196   340 ?        Ss   02:12   0:00 ntpd -s
ntp      11796  0.0  0.0  13984   860 ?        S    02:13   0:00 ntpd -s
root     11801  0.0  0.0  18196   344 ?        Ss   02:13   0:00 ntpd -s
ntp      11916  0.0  0.0  13984   860 ?        S    02:14   0:00 ntpd -s

And if I pipe the ps aux output through grep and wc, I see that there are over a thousand unended ntp-related processes after running the machine for 9 hours,

[root@reformedtube ~]# uptime ; ps aux | grep ntp | wc -l
 02:25:19 up  9:01,  1 user,  load average: 0.06, 0.02, 0.00
1084

Does anyone have any ideas?

Offline

#2 2010-06-20 02:33:58

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Should NTP Processes Never End?

Maybe try ntpdate instead of ntpd -- I think ntpd is the daemon  version. Ntpdate is the run-once version.

Scott

Offline

#3 2010-06-20 02:37:04

rransom
Member
Registered: 2010-04-26
Posts: 92

Re: Should NTP Processes Never End?

'ntpd -s' starts a daemon.

EDIT: This is for ntpd in the 'openntpd' package, not the recommended 'ntp' package.

Last edited by rransom (2010-06-20 04:01:12)

Offline

#4 2010-06-20 02:46:51

rransom
Member
Registered: 2010-04-26
Posts: 92

Re: Should NTP Processes Never End?

If you really need to run NTP as a cron job, install 'ntp', not 'openntpd', and use 'ntpd -q'.  Then add instructions to the [wiki]NTP[/wiki] wiki page (you can copy the instructions you followed, mutandis mutatis, out of the page history; I just zapped that section a few minutes ago because it was clearly bogus).

I don't think you really need to run NTPD as a cron job, though.

Offline

#5 2010-06-20 03:03:40

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

Re: Should NTP Processes Never End?

Wow; thanks for all the tips! I'll try just loading it in the daemons array instead of using a cron job.

Offline

#6 2010-06-20 15:20:19

quigybo
Member
Registered: 2009-01-15
Posts: 223

Re: Should NTP Processes Never End?

Yes, just add it to your rc.conf.

For the record though, the -d option (openntpd) does not daemonise it. Rtfm (in a nice way smile)

Offline

#7 2010-06-21 04:28:12

rransom
Member
Registered: 2010-04-26
Posts: 92

Re: Should NTP Processes Never End?

quigybo wrote:

For the record though, the -d option (openntpd) does not daemonise it. Rtfm (in a nice way smile)

According to the man page, the -d option does not make openntpd quit after synchronizing the clock once.  That is what he would have needed to run it in a cron job.

Offline

#8 2010-06-21 11:32:42

quigybo
Member
Registered: 2009-01-15
Posts: 223

Re: Should NTP Processes Never End?

Yes you are completely right, I normally run it in a terminal so I forgot about that (I should have read the man page better tongue).

You would need to do something like:

ntpd -d -s & sleep 5 && pkill -n ntpd

EDIT: or even:

ntpd -d -s & sleep 5 && kill $!

Last edited by quigybo (2010-06-21 11:39:01)

Offline

Board footer

Powered by FluxBB