LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-08-2010, 12:57 PM   #1
unclejed613
Member
 
Registered: Mar 2009
Posts: 352

Rep: Reputation: 32
linux app for syncing hardware clock?


i need to be able to sync my linux box to something like www.worldtimeserver.com

how? there don't seem to be any 3rd-party apps for it, so is it already in linux?
 
Old 08-08-2010, 01:04 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
ntpdate

It's part of a default Slackware installation.

Last edited by dugan; 08-08-2010 at 01:05 PM.
 
Old 08-08-2010, 02:23 PM   #3
unclejed613
Member
 
Registered: Mar 2009
Posts: 352

Original Poster
Rep: Reputation: 32
tnx.....

i see there's no man page for it, what are the options?
 
Old 08-08-2010, 02:31 PM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Look in /usr/doc/ntp-4.2.6p1/html/ntpdate.html
 
Old 08-08-2010, 02:46 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Yes, the daemon used for syncing computers clocks is called ntp. I suggest running ntp over ntpdate because ntp will adjust for clocks errors whereas ntpdate just sets the time.

http://en.wikipedia.org/wiki/Network_Time_Protocol
http://linux.die.net/man/1/ntpdate

As stated it should be part of the default Slackware installation. What version of slack are you running?
Does /etc/ntp.conf or /etc/rc.d/rc.ntpd exist?
 
Old 08-08-2010, 09:27 PM   #6
unclejed613
Member
 
Registered: Mar 2009
Posts: 352

Original Poster
Rep: Reputation: 32
tnx, the file:/// link didn't work.... the link to the linux web page did.... so how would i go about setting up cron to automatically update my clock once every 24hrs or so? i've been using linux "part-time" for about 10 years, and "full-time" for only about a year, so there's a lot i still need to learn...




edit: so i created a script called "update-time" with this as the execution line:
/usr/sbin/ntpdate www.worldtime.com

i then placed this file in /etc/cron.daily/



so i gather that this script will execute daily? without using crontab? my pc's clock loses about 1/10 minute per day, and it adds up after a while.

Last edited by unclejed613; 08-08-2010 at 10:07 PM.
 
Old 08-08-2010, 10:15 PM   #7
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by unclejed613 View Post
tnx, the file:/// link didn't work.... the link to the linux web page did.... so how would i go about setting up cron to automatically update my clock once every 24hrs or so? i've been using linux "part-time" for about 10 years, and "full-time" for only about a year, so there's a lot i still need to learn...
Hmm, that's right; the file:/// link doesn't work. Odd. Oh well, it should point into your installed ntpd documentation. Just remove the leading file:// part.

If you have a permanent connection to the web, then you should just run ntpd and forget about it. See this thread, which actually gives a good set of example configuration files.

But just make an executable script containing...
Code:
#!/bin/sh
/usr/sbin/ntpd -q -x -g
...and drop it into /etc/cron.daily/ to set the clock once a day if that's what you'd really prefer.
 
Old 08-08-2010, 10:17 PM   #8
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by unclejed613 View Post
edit: so i created a script called "update-time" with this as the execution line:
/usr/sbin/ntpdate www.worldtime.com

i then placed this file in /etc/cron.daily/



so i gather that this script will execute daily? without using crontab? my pc's clock loses about 1/10 minute per day, and it adds up after a while.
Well, it uses root's crontab to run that. Root has a crontab entry of...
Code:
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
Bear in mind that ntpdate will eventually go away.
 
Old 08-09-2010, 08:47 AM   #9
Eternal_Newbie
Member
 
Registered: Jun 2005
Location: The Pudding Isles
Distribution: Slackware
Posts: 573

Rep: Reputation: 59
that's not really the best way to do it. Read http://www.pool.ntp.org/en/ and http://en.wikipedia.org/wiki/NTP_ser...suse_and_abuse for why it is not recomended doing it that way.

Also, www.worldtime.com doesnt appear to accept ntp connections, which you are attempting to do:
Code:
root@foobar:/etc/rc.d# /usr/sbin/ntpdate worldtime.com
 9 Aug 15:37:47 ntpdate[7537]: no server suitable for synchronization found
root@foobar:/etc/rc.d# /usr/sbin/ntpdate www.worldtime.com
 9 Aug 15:38:10 ntpdate[7548]: no server suitable for synchronization found
root@foobar:/etc/rc.d# /usr/sbin/ntpdate ntp.worldtime.com
Error : Name or service not known
 9 Aug 15:40:49 ntpdate[7618]: can't find host ntp.worldtime.com

 9 Aug 15:40:49 ntpdate[7618]: no servers can be used, exiting
If you are using Slackware set up your pool servers in /etc/ntpd.conf and make /etc/rc.d/rc.ntpd executable and then run
Code:
/etc/rc.d/rc.ntpd start
(or restart) as root.

This is my /etc/ntpd.conf, which is just the default slackware one with pool servers added:
Code:
# Sample /etc/ntp.conf:  Configuration file for ntpd.
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
#server  127.127.1.0     # local clock
#fudge   127.127.1.0 stratum 10  
server  0.uk.pool.ntp.org
server  1.uk.pool.ntp.org
server  2.uk.pool.ntp.org
server  3.europe.pool.ntp.org

#
# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift
multicastclient                 # listen on default 224.0.1.1
broadcastdelay  0.008

#
# Keys file.  If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key number to be
# used for making requests.
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote
# systems might be able to reset your clock at will.
#
#keys           /etc/ntp/keys
#trustedkey     65535
#requestkey     65535
#controlkey     65535

# Don't serve time or stats to anyone else by default (more secure)
restrict default noquery nomodify
# Trust ourselves.  :-)
restrict 127.0.0.1
Note I am using UK pool servers. You will want to use pool servers close to you, if possible. Check http://www.pool.ntp.org/en/use.html for details how to do this. If your country has only a couple of pool servers it is better to use the region instead of the country so you don't overtax them. Some regions like Africa have only a few servers as well, so if you are from one of those regions it may be better to specify only 1 or 2 of your servers as a regional one and use worldwide pool servers.

Last edited by Eternal_Newbie; 08-09-2010 at 09:44 AM. Reason: clarified, extra info
 
Old 08-09-2010, 09:04 AM   #10
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by Eternal_Newbie View Post
thats not relly how you should do it. Read http://www.pool.ntp.org/en/ and http://en.wikipedia.org/wiki/NTP_ser...suse_and_abuse for why it is a bad idea doing it that way.
Those links state nothing of the sort that I could see.

Even so, I agree that simply setting up ntpd to run correctly is the better approach; that's what I do.
 
Old 08-09-2010, 09:58 AM   #11
Eternal_Newbie
Member
 
Registered: Jun 2005
Location: The Pudding Isles
Distribution: Slackware
Posts: 573

Rep: Reputation: 59
Quote:
Originally Posted by Richard Cranium View Post
Those links state nothing of the sort that I could see.

Even so, I agree that simply setting up ntpd to run correctly is the better approach; that's what I do.
Sorry I didn't see your reply when I edited my previous post, I'll post what I noticed here as well:
Quote:
Originally Posted by unclejed613
so i created a script called "update-time" with this as the execution line:
/usr/sbin/ntpdate www.worldtime.com

i then placed this file in /etc/cron.daily/
You appear to want to use ntpdate with www.worldtime.com and they don't appear to accept ntp connections:
Code:
root@foobar:/etc/rc.d# /usr/sbin/ntpdate worldtime.com
 9 Aug 15:37:47 ntpdate[7537]: no server suitable for synchronization found
root@foobar:/etc/rc.d# /usr/sbin/ntpdate www.worldtime.com
 9 Aug 15:38:10 ntpdate[7548]: no server suitable for synchronization found
root@foobar:/etc/rc.d# /usr/sbin/ntpdate ntp.worldtime.com
Error : Name or service not known
 9 Aug 15:40:49 ntpdate[7618]: can't find host ntp.worldtime.com

 9 Aug 15:40:49 ntpdate[7618]: no servers can be used, exiting
You need you use a valid ntp server for which you often need permission to access, which is why using the pool servers with ntpd is best.

Last edited by Eternal_Newbie; 08-09-2010 at 10:17 AM. Reason: Clarified again
 
Old 08-09-2010, 10:01 PM   #12
unclejed613
Member
 
Registered: Mar 2009
Posts: 352

Original Poster
Rep: Reputation: 32
i'm using the computer for weak signal decoding, which should use at least a stratum 2 server. JT65 signals only need the computer clock to be within a few seconds, but propagation beacons require somewhat better timing, less than a second IIRC.

you're right about www.worldtime.com, it didn't work. i put in www.worldtimeservers.com and that works, as does wwv.nist.gov (that's not a typo, that's WWV, the NIST's standard time and frequency station, which is local to me.

as far as the misuse and abuse part of it goes, i connect once daily at 1am (not midnight, when i imagine a majority of scripts are running), and the address isn't "hard coded" in firmware, and ntpdate doesn't hammer the connection until it gets a reply. i'm not also producing millions of identical devices and flooding the market with them. on an interesting side note, LG blu-ray players and set-top boxes ping www.whitehouse.gov to determine whether they are still connected to the internet at regular intervals. i don't know what the govt did to piss off LG (maybe the goofy stuff that went on with the DTV switchover, such as forcing companies to mass produce DTV/analog STB's, selling them dirt cheap, and taking a huge hit in their R&D budgets?), but every LG product that is internet capable (blu-ray players, DTV STB's, TV's, etc) is periodically pinging www.whitehouse.gov, just to see if it's still conected...




edit: also, i found KDE's crontab editor to be extremely useful, i didn't even need a handful of hastily scribbled notes to get the process set up...

Last edited by unclejed613; 08-09-2010 at 10:18 PM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
System clock correct, hardware clock wrong karlovac Linux - General 5 01-16-2009 07:19 PM
Failed to set system clock to hardware clock jrtayloriv Linux - Newbie 2 09-25-2008 07:06 AM
ntp is only syncing with local clock. slackamp Linux - Server 2 11-07-2007 03:12 PM
Slow system clock and stray hardware clock, pleas help! Epox Linux - General 6 01-02-2007 02:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration