Friday, August 24, 2007

Tips for Linux

Is NTP Working? STEP 1 (Test the current server): Try issuing the following command: $ ntpq -pn remote refid st t when poll reach delay offset jitter =================================================== tock.usno.navy 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00 The above is an example of a problem. Compare it to a working configuration. $ ntpq -pn remote refid st t when poll reach delay offset jitter ======================================================== +128.4.40.12 128.4.40.10 2 u 107 128 377 25.642 3.350 1.012 127.127.1.0 127.127.1.0 10 l 40 64 377 0.000 0.000 0.008 +128.91.2.13 128.4.40.12 3 u 34 128 377 21.138 6.118 0.398 *192.5.41.41 .USNO. 1 u 110 128 377 33.69 9.533 3.534 STEP 2 (Configure the /etc/ntp.conf): $ cat /etc/ntp.conf # My simple client-only ntp configuration. server timeserver1.upenn.edu # ping -a timeserver1.upenn.edu shows the IP address 128.91.2.13 # which is used in the restrict below restrict 128.91.2.13 server tock.usno.navy.mil restrict 192.5.41.41 server 128.4.40.12 restrict 128.4.40.12 server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 driftfile /etc/ntp/drift restrict default ignore restrict 127.0.0.0 mask 255.0.0.0 authenticate no STEP 3 (Configure /etc/ntp/step-tickers): The values for server above are placed in the "/etc/ntp/step-tickers" file $ cat /etc/ntp/step-tickers timeserver1.upenn.edu tock.usno.navy.mil 128.4.40.12 The startup script /etc/rc.d/init.d/ntpd will grab the servers in this file and execute the ntpdate command as follows: /usr/sbin/ntpdate -s -b -p 8 timeserver1.upenn.edu Why? Because if the time is off ntpd will not start. The command above set the clock. If System Time deviates from true time by more than 1000 seconds, then, the ntpd daemon will enter panic mode and exit. STEP 4 (Restart the service and check): Issue the restart command /etc/init.d/ntpd restart check the values for "ntpq -pn", which should match step 1. ntpq -pn SPECIAL NOTE: Time is always stored in the kernel as the number of seconds since midnight of the 1st of January 1970 UTC, regardless of whether the hardware clock is stored as UTC or not. Conversions to local time are done at run-time. So, it's easy to get the time in different timezones for only the current session as follows: $ export TZ=EST $ date Mon Aug 2 10:34:04 EST 2004 $ export TZ=NET $ date Mon Aug 2 15:34:18 NET 2004

No comments: