LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   ntpq -p: Connection refused (https://www.linuxquestions.org/questions/slackware-14/ntpq-p-connection-refused-4175446458/)

stf92 01-20-2013 07:07 AM

ntpq -p: Connection refused
 
1 Attachment(s)
Slackware 14.0

Hi: The system time is always lagging by a multiple of one hour. But see this:
Code:

root@darkstar:~# ntpq -p
ntpq: read: Connection refused
root@darkstar:~#

I attach my /etc/ntp.conf, in case the reader can draw some conclusion.

tronayne 01-20-2013 09:29 AM

Sounds like the server isn't running -- do you get something like this:
Code:

fubar-root-/root: ps -ef | grep ntpd
root      8160    1  0 04:40 ?        00:00:00 /usr/sbin/ntpd -g -p /var/run/ntpd.pid
root      8593  8559  0 10:27 pts/0    00:00:00 grep ntpd

(and only one running server).

stf92 01-20-2013 09:34 AM

Code:

root@darkstar:~# ps -ef|grep ntp
root    11315 11294  0 09:32 pts/0    00:00:00 grep ntp
root@darkstar:~#

No server running! I had it OK in 12.0 (This is 14.0).

kikinovak 01-20-2013 09:54 AM

http://docs.slackware.com/howtos:network_services:ntp?s[]=ntp

tronayne 01-20-2013 10:13 AM

Quote:

Originally Posted by stf92 (Post 4874104)
Code:

root@darkstar:~# ps -ef|grep ntp
root    11315 11294  0 09:32 pts/0    00:00:00 grep ntp
root@darkstar:~#

No server running! I had it OK in 12.0 (This is 14.0).

You probably need to take a look at /etc/ntp.conf (make sure you're configured for Argentina and all that) and
Code:

root: chmod 755 /etc/rc.c/rc.ntpd
then start it manually (it will get started at boot when rc.ntpd is executable).
Code:

root: /etc/rc.d/rc.ntpd start
You may want to set the date and time manually before starting NTP -- use ntpdate or just set it with date; you want to get the clock close.

Oop! Forgot. Paste this into your browser: /usr/doc/ntp-4.2.6p5/html/ntpdate.html if you don't already know how to use ntpdate.

Hope this helps some.

stf92 01-20-2013 10:45 AM

Oh yes, dear Sir. I have used ntpdate before, to set the time, but thank you, thank you very much for the link. Now, I think the problem ought to be somewhere else. Because look at this:[quote]
root@darkstar:/etc# ls -l /etc/rc.d/rc.ntpd
-rwxr-xr-x 1 root root 804 2012-07-04 13:38 /etc/rc.d/rc.ntpd*
root@darkstar:/etc#
[/code]
The execute bit is on. On the other hand, I copied rc.ntpd from my 12.0 install to this one (14.0). It's impossible that all of the servers listed there are out of service (I gave a link to it in post #1).

michaelk 01-20-2013 11:14 AM

Either ntp is not starting at boot time or your local clock is off by more then is acceptable and ntp is just quitting. Have you checked the logs? Have you tried manually starting ntpd?

With the current version of ntp the -g option should force the time to be set first prior to the daemon actually trying to synch with a server. This is the same as running ntpdate first then ntpd.

If ntp is starting and can't find a time server to synch,it will revert back to the local clock. This is the purpose of the fudge server in the ntp.conf file.

kikinovak 01-20-2013 11:32 AM

1) Proceed to an initial adjustement with 'ntpdate' while 'ntpd' is NOT running.

2) Configure /etc/ntp.conf.

3) Activate and start rc.ntpd.

Everything is explained in the HOWTO (see link above). Here's my original documentation:

http://www.microlinux.fr/slackware/L.../NTP-HOWTO.txt

stf92 01-20-2013 12:03 PM

Quote:

Originally Posted by michaelk (Post 4874144)
Either ntp is not starting at boot time or your local clock is off by more then is acceptable and ntp is just quitting. Have you checked the logs? Have you tried manually starting ntpd?

I'm sure I did both things but, just in case I'm wrong, I do them again.

This is the last line in /var/log/ntp.log:
Code:

19 Jan 00:34:58 ntpd[1621]: 0.0.0.0 0617 07 panic_stop +10803 s; set clock manually within 1000 s.
What happened at 00:34:58. Was ntpd execution cancelled? Because is not running now. I do
Code:

dmesg -s 32000|grep ntpd
and see that ntpd is not there.

So, sometimes, at startup, it starts and sometimes not?
As it says "set clock manually within 1000 s but the clock lags by double that quantity, I set the clock (date) at 00:34:58 + 1000s (not really now, but in the past).

I'll do this: set the clock with ntpdate at current local time and then start the script and watch for at least 24hs to see what happens.

tronayne 01-20-2013 12:05 PM

Quote:

Originally Posted by stf92 (Post 4874134)
The execute bit is on. On the other hand, I copied rc.ntpd from my 12.0 install to this one (14.0). It's impossible that all of the servers listed there are out of service (I gave a link to it in post #1).

Uh, did you mean that you copied /etc/ntp.conf (rather than /etc/rc.d/rc.ntpd)? The linked file from your earlier post looks OK to me.

This might be a silly question, but can you ping the servers you specified in ntp.conf? That would tell you that whatever DNS server you use can resolve the addresses and that those time servers are active (eliminating two potential problems).

I notice in your atachment that you're logging -- does the log show you anything? Oh, yeah, did you manually create the log file (it doesn't exist by default) with something like
Code:

root: touch /var/log/ntp.log
Hope this helps some.

stf92 01-20-2013 12:17 PM

Quote:

Originally Posted by tronayne (Post 4874169)

This might be a silly question, but can you ping the servers you specified in ntp.conf? That would tell you that whatever DNS server you use can resolve the addresses and that those time servers are active (eliminating two potential problems).

Only if you tell me what "to ping" is.


Quote:

I notice in your atachment that you're logging -- does the log show you anything? Oh, yeah, did you manually create the log file (it doesn't exist by default) with something like
Code:

root: touch /var/log/ntp.log

I never did that.

tronayne 01-20-2013 12:44 PM

The ping utility sends echo requests to network hosts. For example, I pinged one of your time servers:
Code:

ping -c 5 3.ar.pool.ntp.org
PING 3.ar.pool.ntp.org (170.210.222.2) 56(84) bytes of data.
64 bytes from 170.210.222.2: icmp_req=1 ttl=43 time=1051 ms
64 bytes from 170.210.222.2: icmp_req=2 ttl=40 time=1211 ms
64 bytes from 170.210.222.2: icmp_req=3 ttl=40 time=1139 ms
64 bytes from 170.210.222.2: icmp_req=4 ttl=40 time=1121 ms
64 bytes from 170.210.222.2: icmp_req=5 ttl=40 time=1478 ms

--- 3.ar.pool.ntp.org ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 6702ms
rtt min/avg/max/mdev = 1051.162/1200.628/1478.676/148.132 ms, pipe 2

Bear in mind that I'm a continent away from you and your results should be much faster than shown here. The utility is handy for finding out if a site is running, how long it takes for a transmission to go from you to there and back again, stuff like that; read the manual page if you're interested.

You do need to create that log file.

Hope this helps some.

stf92 01-20-2013 01:12 PM

I'll skim through ping's manual and use it. I do have a log file created, /var/log/ntp.log and I'm watching its contents now, as I have done in the past. I did:
  • ntpdate <server_name>
    where server_name is one of those listed in /etc/ntp.conf. I communicated with the server and the date/time was correctly set (it matched my time).
  • /etc/rc.d/rc.ntpd start
in that order. Now I'm reading /var/log/ntp.log and it follows local time.

In my past tries to fix the problem, I skipped the second step above. I do not say things are OK now. I have to keep an eye on it and see what happens. And of course, to thank you. Cheers.

tronayne 01-20-2013 02:04 PM

If you give ntpd at least five minutes of run time, it should sync up with one of the servers you have defined in ntp.conf; if you execute
Code:

fubar-trona-/home/trona: /usr/sbin/ntpq -pn
    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 127.127.1.0    .LOCL.          10 l  10h  64    0    0.000    0.000  0.000
+64.34.171.122  198.60.22.240    2 u  296 1024  377  947.405  -237.04 425.531
*173.255.219.242 23.213.115.25    2 u  440 1024  377  1223.21  123.271 134.556
+66.232.97.8    149.20.64.28    2 u  386 1024  377  1278.66  -94.157 208.588

You use -pn so you won't contact a DNS server to show you the names of the sites and it's faster getting the display (and, basically, you don't care what the names of the sites are anyway).

In the display above, the asterisk indicates the time server ntpd has synchronized with and the other two are candidates for connection if that server goes away for whatever reason.

If you don't see something similar to the above (where a server has synchronized) after 5- to 10 minutes, then you've got a problem to deal with. Once NTP synchronizes, it's going to stay synchronized as long as your network connection remains alive and there are pool servers to connect with. Periodically, NTP will get a batch of new pool servers if the ones it already has start to go bad; it will also occasionally evaluate the connections and drop one that's not good enough and request another from the pool server.

Hope this helps some.

stf92 01-20-2013 03:19 PM

My output to ntpq -pn is quite like yours. Now, I do not understand what happened just after 14.0 installation. All should have worked out of the box, I mean this problem should never have happened.


All times are GMT -5. The time now is 11:36 PM.