LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-12-2006, 06:01 PM   #1
sunman
Member
 
Registered: Jun 2005
Distribution: Slackware64 13.0 (multilib)
Posts: 67

Rep: Reputation: 15
Time sync question


I found a little two-line script in one of the posts here at lq but am having a problem with it.

Code:
/usr/sbin/ntpdate time-a.nist.gov
/sbin/hwclock -w
I get a slight clock drift as I understand most pcs do so I added a script called updatetime in root's cron.weekly to keep the time set. The problem I'm having is that it sets my clock 5 hours ahead of the time it should be.

My timezone is set to America/Detroit if it's any help, but I'm not sure what to do to fix this.

Edit:I ran the script from the command line and the output is -
host found : time-a.nist.gov
13 Mar 00:01:30 ntpdate[4619]: step time server 129.6.15.28 offset 18004.022737 sec
The offset it shows is where the extra five hours are coming from I'd assume but still no idea where to change that from. Btw, is it just my system or is ntpdate missing the man page? I found it online but thought it was odd that it's missing.

Last edited by sunman; 03-12-2006 at 06:08 PM.
 
Old 03-12-2006, 06:17 PM   #2
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Check this link out. http://www.hypexr.org/linux_date_time_help.php

Brian1
 
Old 03-12-2006, 06:48 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
The five hour offset is the difference between your local time zone and UTC (coordinated universal time), formerly referred to as GMT (Greenwich Meantime). I once had a similar problem and my (Slackware) solution was two steps. With root privileges:

1. From the command line, run the timeconfig script.
2. Because I run KDE, configure the KDE clock utility. (Do this after running timeconfig).
 
Old 03-12-2006, 11:56 PM   #4
sunman
Member
 
Registered: Jun 2005
Distribution: Slackware64 13.0 (multilib)
Posts: 67

Original Poster
Rep: Reputation: 15
Thanks for the info, I ran timeconfig and set it to utc time and everything seems work alright now. The script sets the time correctly.

One other question though, is there some other way to do this to let it play nice for dual-booting with windows? I noticed another post saying something about it so I rebooted to check and now the time is off for windows by 5 hours.
 
Old 03-13-2006, 06:30 AM   #5
Xian
Member
 
Registered: Feb 2004
Location: 33.31N -111.97W
Distribution: SuSE
Posts: 919

Rep: Reputation: 32
AFAIK if you dual boot with Win you should set your clock to 'local' and not 'UTC'.
 
Old 03-13-2006, 06:56 AM   #6
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Try using ntpd service.
 
Old 03-13-2006, 09:39 AM   #7
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Please, please, PLEASE check out how to use pool time servers rather than connect directly to a specific one. There is an increasing problem that the main timeservers (like NIST) are getting absolutely pounded by people who don't need that level of accuracy. That does two things: First, the people who do need that level of accuracy have much more trouble getting it and second, it means that NIST and other top-tier time servers are seriously considering stopping their public time-servers altogether.
 
Old 03-13-2006, 11:01 AM   #8
sunman
Member
 
Registered: Jun 2005
Distribution: Slackware64 13.0 (multilib)
Posts: 67

Original Poster
Rep: Reputation: 15
Ok, for now until I figure out a better way to do this I've just rerun timeconfig and set the clock back to local and moved the cron script out. I can completely understand not pounding a single server a lot, which is why I set it to be a once a week job rather than a daily/hourly thing in the first place. Hell, a once a month sync would suit me just fine. Doing a bit of quick reading while I had a few minutes, I don't think I need anything like a daemon running just to keep my clock setup. The pools I have already read about and was working toward using them as, like I already said, I can imagine the stress of all the folks that hit a single server. Just was trying to get something working.

It seems odd to me that there's no apparent way to make an adjust from the UTC time the ntp services grab back to your own local time though, and since I dual-boot having the time right in both os's works better for me at the moment
 
Old 03-13-2006, 11:15 AM   #9
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 55
Once your time zone is set correctly, ntpdate does set your local time. I'm running it here on Slackware 10.2 and it works fine. The problem is accuracy- I read some posts and some info on the ntp website and it sounds pretty complicated to do properly.
 
Old 03-13-2006, 11:20 AM   #10
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
I think,it grabs UTC time and converts it into your local (that's why you are selecting timezone) timezone format.
 
Old 03-13-2006, 11:36 AM   #11
sunman
Member
 
Registered: Jun 2005
Distribution: Slackware64 13.0 (multilib)
Posts: 67

Original Poster
Rep: Reputation: 15
Ah yes, once it's setup right it does work correctly Just have to make sure that /etc/localtime exists and that it points to the correct timezone. I know that I picked my timezone when I did my install here, but for some reason all I ever saw in /etc was a symlink called localtime-copied-from, but no file or link called localtime. Now, after running timeconfig the last couple of times, that file does indeed exist and ntpdate does set the time correctly.

Since I'm in the U.S., I modified the little two line cron script to be -
Code:
#!/bin/sh
/usr/sbin/ntpdate us.pool.ntp.org
/sbin/hwclock -w
Ran it once to test, and works perfectly. As far as accuracy goes, comparing the running clock (after the sync) to http://www.time.gov shows maybe a difference of not quite 1 second, which is fine by me. I'm not doing rocket science, just would like, every once in a while, to make sure my time is set correctly. So I would think that making this script a once a month cron job will be fine for me.

Thanks everyone for the input and help.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set and sync system time with time server?? servnov Linux - Newbie 6 12-03-2013 07:55 PM
software of time sync hongxing Linux - Software 5 10-12-2005 03:18 AM
Time sync? fredws Mandriva 1 10-01-2003 08:38 PM
Sync time u4113072 Linux - General 2 11-21-2002 10:28 AM
Time sync cyclopiea Linux - General 6 10-17-2002 06:43 AM

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

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