LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 01-25-2013, 03:32 AM   #1
ybsshweta
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Rep: Reputation: Disabled
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?

So..
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?
 
Old 01-25-2013, 03:40 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

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

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.
 
Old 01-25-2013, 07:18 AM   #3
RandyTech
LQ Newbie
 
Registered: Oct 2010
Posts: 23

Rep: Reputation: 1
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:

Code:
vi /etc/hosts  # add the following line to your hosts file.
	46.19.33.5	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 http://www.pool.ntp.org/en/ to find the NTP server in your country (area) and use ping at your Windows computer to get the numeric address:
Code:
#example:
ping 0.us.pool.ntp.org
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:
Code:
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!!

Last edited by RandyTech; 01-25-2013 at 10:01 AM.
 
Old 01-25-2013, 08:35 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 1,702

Rep: Reputation: 426Reputation: 426Reputation: 426Reputation: 426Reputation: 426
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.
 
2 members found this post helpful.
Old 01-25-2013, 10:00 AM   #5
RandyTech
LQ Newbie
 
Registered: Oct 2010
Posts: 23

Rep: Reputation: 1
Quote:
Originally Posted by jpollard View Post
... 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.
 
Old 01-25-2013, 12:11 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

Rep: Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945
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?
 
Old 01-28-2013, 11:36 PM   #7
ybsshweta
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
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?
 
Old 01-29-2013, 02:14 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

Rep: Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945
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)
 
Old 01-29-2013, 02:38 AM   #9
ybsshweta
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
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?
 
Old 01-29-2013, 02:40 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

Rep: Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945
heh, ok well I learnt something there, yes 5 seconds on google says that NTP does use 1900. so there you go.
 
Old 01-29-2013, 02:57 AM   #11
ybsshweta
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
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?
 
Old 01-29-2013, 02:59 AM   #12
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

Rep: Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945
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.
 
Old 01-30-2013, 12:34 AM   #13
ybsshweta
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hello chris,

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

root@navikatest-desktop:~# ntpdate -v 192.168.1.28
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 192.168.1.28
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 192.168.1.28 and service ntp
host found : 192.168.1.28
transmit(192.168.1.28)
receive(192.168.1.28)
transmit(192.168.1.28)
receive(192.168.1.28)
transmit(192.168.1.28)
receive(192.168.1.28)
transmit(192.168.1.28)
receive(192.168.1.28)
transmit(192.168.1.28)
192.168.1.28: Server dropped: Leap not in sync
server 192.168.1.28, 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
 
Old 01-30-2013, 02:06 AM   #14
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,345

Rep: Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945Reputation: 1945
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 192.168.1.28" 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.
 
Old 01-30-2013, 06:24 AM   #15
ybsshweta
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks Chris
that leap indicator problem is solved. There was a problem with server side.

Now system time is syncing with the server time
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to sync time NTP server Rohit_4739 Linux - Newbie 5 04-10-2012 08:44 AM
NTP time sync with windows 2000 AD time csghosh Linux - Enterprise 7 02-24-2012 03:46 PM
[SOLVED] Slackware server - ntp time sync stops after a day tennis_slacker Slackware 81 08-04-2010 09:05 AM
LXer: Network Time Protocol (NTP) Server and Client Setup in Ubuntu LXer Syndicated Linux News 0 08-06-2008 12:10 PM
Sync KDE/System Time w/ NTP carlosinfl Linux - General 6 03-15-2006 03:37 PM


All times are GMT -5. The time now is 06:52 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration