LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-17-2008, 12:08 PM   #1
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Rep: Reputation: 48
update system time from internet


Is it possible that i point local time to an internet address. I want to update my local time from internet, as my CMOS battery is not in best of shape... :-P
 
Old 09-17-2008, 12:15 PM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
ntpdate <servername>

will sync your system time to the server you specify. Do a google search for
"public ntp servers" and you'll most likely find one in you area of the world,
or check to see if your isp has their own.

If you want to get serious you could always configure ntpd to constantly adjust the time, but for most folk that's overkill and a ntpdate on bootup or once a day is probably more than enough.

edit:

forgot to say: you'll need to run it as root for obvious reasons.
 
Old 09-17-2008, 12:49 PM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
ntpdate will only update the system time though, if you want to update the internal hardware clock from the system time after a ntpdate:

hwclock --systohc
 
Old 09-17-2008, 01:38 PM   #4
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
I run the ntp daemon on my primary box. I have the other boxes on my SOHO LAN sync with my primary box. Perhaps the following might help:

Configuring the NTP Daemon
 
Old 09-17-2008, 01:38 PM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by keefaz View Post
ntpdate will only update the system time though, if you want to update the internal hardware clock from the system time after a ntpdate:

hwclock --systohc
Saving system time to the hardware clock is included in the system shutdown scripts so it isn't strictly necessary to do this, though it won't hurt any.
 
Old 09-17-2008, 02:15 PM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I did not know that, I guess I should look more often in those /etc/rc.d/* scripts
 
Old 09-17-2008, 03:07 PM   #7
Jeebizz
Senior Member
 
Registered: May 2004
Distribution: Slackware15.0 64-Bit Desktop, Debian 11 non-free Toshiba Satellite Notebook
Posts: 4,186

Rep: Reputation: 1378Reputation: 1378Reputation: 1378Reputation: 1378Reputation: 1378Reputation: 1378Reputation: 1378Reputation: 1378Reputation: 1378Reputation: 1378
This is a good idea, and I probably should consider this since my battery is also screwed. After 9 years of use, what did I expect? Of course having ntpd on boot for me is not much of an option, because I don't ever shutdown, or ever reboot, unless there is a power outage. So I might need to have ntpd run at certain intervals since my system time goes out of sync in a day or so. I guess battery problems cause different problems for users. In my case, the time on my machine actually ends up being AHEAD of my actual local time.. (CST)

So now, according to my mobile phone, it is 3:06 p.m., but my system time says 3:14.... If I am to keep it like this, sooner or later it would end up being an hour ahead of what my actually time is.

Last edited by Jeebizz; 09-17-2008 at 03:17 PM.
 
Old 09-17-2008, 03:30 PM   #8
AuroraCA
Member
 
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
You can set up a simple crontab entry that will update the clock at fixed intervals, every 15 minutes, every hour, once every 24 hours or at whatever interval you choose.
 
Old 09-18-2008, 06:25 AM   #9
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Rep: Reputation: 55
Quote:
Originally Posted by Woodsman View Post
I run the ntp daemon on my primary box. I have the other boxes on my SOHO LAN sync with my primary box. Perhaps the following might help:

Configuring the NTP Daemon
I saw this tutorial, but it seems to be a bit old. I mean, in stock 12.1 there are both /etc/ntp.conf and /etc/rc.d/rc.ntpd. The npd daemon is running by default in 12.1 and I think this is why when I issue as root:
Code:
root@marto:~# ntpdate ntp.host.bg
I get:
Code:
18 Sep 14:16:21 ntpdate[17019]: the NTP socket is in use, exiting
Probably we should somehow just modify the ntp.conf file to adjust it to a relevant local time server rather than to localhost 127.0.0.1?
I would be thankful if you post your suggestions for the modifications needed.
 
Old 09-18-2008, 06:45 AM   #10
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
You should disable /etc/rc.d/rc.ntpd (chmod -x /etc/rc.d/rc.ntpd)
so it won't start at boot, you want to use ntp as client, you don't want to set a time server, right ?
 
Old 09-18-2008, 06:51 AM   #11
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Rep: Reputation: 55
Quote:
Originally Posted by keefaz View Post
You should disable /etc/rc.d/rc.ntpd (chmod -x /etc/rc.d/rc.ntpd)
so it won't start at boot, you want to use ntp as client, you don't want to set a time server, right ?
So it is. I already killed the running ntpd and used ntpdate successfully. What you say is an option, of course. But isn't there some easy modification of the default scripts to set them to a local time server?
 
Old 09-18-2008, 06:59 AM   #12
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I don't know, I wonder what is the use of a local time server...
I just use ntpdate for my part (I set an entry in root crontab to update it once a day)
 
Old 09-18-2008, 07:39 AM   #13
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by keefaz View Post
I don't know, I wonder what is the use of a local time server...
I just use ntpdate for my part (I set an entry in root crontab to update it once a day)
ntpd is mostly used in clustered environments where serveral nodes interoperate with each other and sub-second accuracy on timestamps is significant.

For a single host, running ntpdate every so often should be more than adaquate.

The hardware clock on this 8 year old Dell XPS P3-800 appears to drift by about 6 seconds a day here.
 
Old 09-18-2008, 07:58 AM   #14
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I see your point GazL but "in clustered environments" means that ntpd serves time on other hosts than localhost so it is not a local time server anymore, I mean there are local servers where I can see the usability like X server, cups server but why running a local time server ? I think it is redundant with the system time
 
Old 09-18-2008, 10:36 AM   #15
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
keefaz, the difference is that ntpd constantly adjusts the speed of the system clock where as ntpdate makes a step change. Some software will break if you do a step change to the system time, so in those cases you use ntpd, even if only to govern time on the local host.

Say ntpd notices that your system time is 1/10th of a second behind real time. It will do something along the lines of making each of the next 10 seconds last for only 99/100th of a second. So over that 10 seconds you gain 1/10th, but they're gained so slowly that the software doesn't notice. In contrast ntpdate just comes along and goes "Bang!... there's an extra 1/10th for you"

The above figures are for example only, ntpd operates at a much finer interval and takes a long time to apply the adjustments and its a little bit more involved than the way I describe it. If you look at the man page for ntpd, you'll notice that they quote a duration of 14 days to apply an adjustment to the clock of 10 minutes.

The purpose of the ntpd server deamon is not only to communicate the time with other hosts, but to also manage these fine adjustments on the local host.

Interesting stuff isn't it!
 
  


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 time vs Hardware time and Daylight Savings Time Toadman Linux - General 6 03-17-2007 08:12 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - Networking 6 03-16-2007 07:14 PM
Where does RH8 daily set system time to hardware clock time smartnorman Red Hat 1 05-24-2006 02:42 PM
Setting System Time: kernel in wrong time zone warrenweiss Linux - General 7 05-15-2004 03:25 PM

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

All times are GMT -5. The time now is 01:44 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