-   Linux - Newbie (
-   -   How to make my system time to sync with ntp server without using client software? (

ybsshweta 01-25-2013 03:32 AM

How to make my system time to sync with ntp server without using client software?
We have the Unit which incorporated with ntp server and it is connected to the local subnet. if i run client software(developed by us) in my pc then it is syncing with that server but how can we do this without running client software?

now my questions are
1)is it possible to sync my system time with that ntp server?
If Yes, how to make it?

2)i tried with executing the following command
ntpdate unit_ip_address

It is showing like " No server suitable for Synchronization" what may be the reason to give this error?

acid_kewpie 01-25-2013 03:40 AM

you can't make any computer do *anything* without "running software"... :confused:

for ntpdate, add a -v to the commadn line and show us the full output.

in general, running ntpd is the proper solution to keep time constantly synchronized.

RandyTech 01-25-2013 07:18 AM

I keep my systems secure as possible and that includes disabling access to DNS servers. Instead I prefer to use the local host file for alias lookup. This is the cleanest most reliable config I have come up with:


vi /etc/hosts  # add the following line to your hosts file.        ntpserver

service ntpd stop  # need YUM update to proceed further if you get error.
chkconfig --level 2345 ntpd off
/usr/sbin/ntpdate ntpserver
vi /var/spool/cron/root  # to add the following lines
        # NTP TIME SYNC
        00 6 * * * /usr/sbin/ntpdate ntpserver > /dev/null 2>&1
        # NTP TIME SYNC

service crond restart

Check to find the NTP server in your country (area) and use ping at your Windows computer to get the numeric address:


Use the numeric address returned from your ping to replace the numeric address in my hosts file example line above.

If you encounter not found error on "service ntpd stop" command then you need to install the package:

yum install ntp
The root cron will sync your system every day at 0600 hour (6:00AM).

NOTE: The reason I prefer this method, it does not leave the extra ntpd process running full time as it would if you used the "chkconfig --level 2345 ntpd on" method... hence, a cleaner process list.

[EDIT] Be sure to review comments from jpollard in the next post!!

jpollard 01-25-2013 08:35 AM

The use of cron to resync works just fine for most things.

If your clock is really drifty, it won't necessarily be accurate enough when mixed with file servers. The client systems clock drifts one way, and the server drifts another. The combined difference can cause files to be created that appear "in the future" when the server drifts ahead, and the client drifts behind... This can play havok with some utilities (make is one that has problems).

This is what the ntpd service handles - by frequently checking the local system clock with the time reference. Using the combined information, ntpd can compute a "drift rate" value that helps keep the clock accurate - by compensating for a known drift rate. Ntpd also removes one problem caused by using cron.

The cron solution causes the clock to jump, either forward or backward. Forward jumps are not much of a problem - backward jumps can cause files to "be in the future" until the clock advances past the delta. Ntpd can handle this even when the reference time is unavailable by using the drift value to gradually change the clock (see "adjtime" library funtion) that retards/advances the clock in a gradual manner. Basically, the clock is advanced by a set amount time based on the clock frequency. The adjustment (assuming 1000 Hz) is 1000... the adjtime shifts this value up (greater than 1000 to advance the clock) or down (less than 1000 to reduce the time) for the duration of the change. This prevents abrupt time changes from causing problems.

RandyTech 01-25-2013 10:00 AM


Originally Posted by jpollard (Post 4877372)
... ntpd can compute a "drift rate" value that helps keep the clock accurate - by compensating for a known drift rate. Ntpd also removes one problem caused by using cron...

Indeed an interesting note and something to keep in mind. Didn't realize it imparted any intelligence beyond the act of basic correction so thanks for the tip. Systems I work with are not subject to distinguishable drift day-to-day so cron method remains the cleanest solution for our needs.

acid_kewpie 01-25-2013 12:11 PM

cron is not "cleaner" there are lots of simple solutions out there, and ntpd is possibly the simplest. It's a doddle. Why use cron for a less than ideal solution, when the ideal solution is no less hassle?

ybsshweta 01-28-2013 11:36 PM

1)NTP client software sends request(timestamps related to 1900 epoch) to NTP server
2)NTP server sends responses back to NTP client(timestamps related to 1900 epoch)

Is my understanding is Correct?

If correct,
does ntpdate/ntpd command will send NTP request to NTP server using 1900 as epoch?

acid_kewpie 01-29-2013 02:14 AM

1900 epoch? What?

Both programs speak ntp, hence the name. They don't have the right to send different types of request. They send NTP requests, and there's a huge amount more to it that when they take zero to be (which is 0:00 1/1/1970 btw)

ybsshweta 01-29-2013 02:38 AM

Hello Chris,

1990 epoch means NTP reference time(First day NTP Era 0 i.e 1-Jan-1900)

my question is:
Timestamps (in seconds) in NTP request/response are with respect to the epoch 1-Jan-1900 or 1-jan-1970?

acid_kewpie 01-29-2013 02:40 AM

heh, ok well I learnt something there, yes 5 seconds on google says that NTP does use 1900. so there you go.

ybsshweta 01-29-2013 02:57 AM

Thanks Chris..

now my doubt is
when i execute ntpdate command, internally it will take system time and converts it in to time with respect to NTP epoch(i.e 1-1-1900)then packs this converted time in to NTP Request and sends the same to NTP server

Is my understanding is correct?

acid_kewpie 01-29-2013 02:59 AM

no. If you think about it, why would the client ever send its time to the server? The correct time is absolute, ntp clients just ask what that time is from servers, and what proof they have that they are correct.

ybsshweta 01-30-2013 12:34 AM

Hello chris,

the following is the output of ntpdate -v is our unit(time server) ip address which is connected to our local subnet

root@navikatest-desktop:~# ntpdate -v
30 Jan 11:56:48 ntpdate[2855]: ntpdate 4.2.4p8@1.1612-o Tue Apr 19 07:08:30 UTC 2011 (1)
30 Jan 11:56:48 ntpdate[2855]: no server suitable for synchronization found

root@navikatest-desktop:~# ntpdate -d
30 Jan 12:03:40 ntpdate[2894]: ntpdate 4.2.4p8@1.1612-o Tue Apr 19 07:08:30 UTC 2011 (1)
Looking for host and service ntp
host found :
transmit( Server dropped: Leap not in sync
server, port 123
stratum 1, precision 0, leap 11, trust 000
refid [GPS], delay 1.02545, dispersion 0.00002
transmitted 4, in filter 4
reference time: d4b33d49.00000000 Wed, Jan 30 2013 12:03:45.000
originate timestamp: d4b33d49.5e05a5a5 Wed, Jan 30 2013 12:03:45.367
transmit timestamp: d4b33d49.493671ac Wed, Jan 30 2013 12:03:45.285
filter delay: 1.02588 1.02565 1.02545 1.02565
0.00000 0.00000 0.00000 0.00000
filter offset: 0.081145 0.080981 0.081035 0.081083
0.000000 0.000000 0.000000 0.000000
delay 1.02545, dispersion 0.00002
offset 0.081035

30 Jan 12:03:45 ntpdate[2894]: no server suitable for synchronization found

acid_kewpie 01-30-2013 02:06 AM

looks like that server is not synced itself. from googling (I hope you did too...??) leap is a officially a leap second indicator, UNLESS it's 11, which means the server is just not synchronized.

Have a look at the server you're trying to sync to, or pick a different server. Running "ntpq -pn" should show you the status of the server in a more readable status. Fundamentally though, this all looks like NTP doing it's thing correctly.

ybsshweta 01-30-2013 06:24 AM

Thanks Chris
that leap indicator problem is solved. There was a problem with server side.

Now system time is syncing with the server time

All times are GMT -5. The time now is 12:22 AM.