View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 7 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sun Feb 25, 2007 4:40 am 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
This simple method will sync your hardware clock to a time sever every 4 hours and at boot AND log the output so you can keep track of how badly your clock is drifting.

I believe the out-of-the-box R5E50 and R5D1 both have ntp-server setup to run for you. This is fine for most users, but if you have an nforce2 chipset (which is known to have clock drift) you may want to track how badly your clock is drifting while updating the clock to a time sever. As usual when you see a command shown with the # prompt it's something you need to do as the root user. If it's shown with the $ prompt, it should be done from the mythtv user.

BTW, as true with all howtos I've wrote, there are other perfectly acceptable ways to accomplish the task; this is just how I did it.

Disable the /etc/init.d/ntp-server so you don't get a "socket in use error":
Code:
# update-rc.d remove ntp-server


Then do this:
Code:
# crontab -e

Add these lines:
Code:
@reboot /usr/sbin/ntpdate 2.pool.ntp.org >> /var/log/gettime.log
0 0-23/4 * * * /usr/sbin/ntpdate 2.pool.ntp.org >> /var/log/gettime.log


That's it. as you can see, cron will run the job everyday at midnight, 4 AM, 8 AM, noon, 4 PM, and 8 PM as well as at the system boot. To inspect the log file, simply nano it from /var/log/gettime.log and it will report any clock drift there.

--

EDIT 06-Mar-07: Read tjc's comments. I think a better solution is to NOT stop ntp-server and simply add the @reboot line to your crontab. That should give you the best of both worlds (sync time @ boot when it can't hurt any running time-dependent processes and use the ntp-server the rest of the time).

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Last edited by graysky on Tue Mar 06, 2007 12:20 pm, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 25, 2007 9:38 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Beware that sudden time jumps can cause squirrelly behavior in apps that are time sensitive like MythTV, the ntpd approach should be used whenever possible.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 3:23 pm 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
As always, thanks for the info, tjc. How does ntpserver sync the clock differently then a manual (or cron job) of ntp-date?

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 8:59 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Gradually. Basically it makes the system clock add extra ticks or skip ticks on some percentage of the clock interupts using the adjtime() system call.

When you force it with ntpdate it just jumps, possibly by minutes. As you can imagine this messes with software that assumes that the clock will smoothly increase over time.

This is part of the reason why the system time is kept in UTC, since it avoids discontinuities due to DST or for mobile machines that move from timezone to timezone...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 3:01 pm 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
Interesting, thanks. So perhaps the best scenario would be to call my script at bootup (since no mythbackend isn't running in case the clock does skip) and use the ntpserver the rest of the time.

Last question: is there a way to log the output of the ntpserver (or is it logged natively)?

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 7:55 am 
Offline
Joined: Tue Apr 13, 2004 6:51 pm
Posts: 890
Location: Groton, MA
I see this on my box....

Code:
 grep ntp /var/log/*
/var/log/daemon.log.0:Mar  1 16:36:41 mythtv ntpd[3545]: time reset +0.312069 s
/var/log/daemon.log.0:Mar  1 16:43:09 mythtv ntpd[3545]: synchronized to 64.251.30.199, stratum 3
/var/log/daemon.log.0:Mar  1 16:43:09 mythtv ntpd[3545]: time reset -0.156080 s
/var/log/daemon.log.0:Mar  1 16:47:26 mythtv ntpd[3545]: synchronized to 64.251.30.199, stratum 3
/var/log/daemon.log.0:Mar  1 17:36:53 mythtv ntpd[3545]: time reset -0.324241 s
/var/log/daemon.log.0:Mar  1 17:41:12 mythtv ntpd[3545]: synchronized to 64.251.30.199, stratum 3
/var/log/daemon.log.0:Mar  1 18:48:35 mythtv ntpd[3545]: time reset +0.162760 s
/var/log/daemon.log.0:Mar  1 18:58:17 mythtv ntpd[3545]: synchronized to 64.251.30.199, stratum 3

_________________
R5F1 - Dell P4 2.4Ghz 500MB - PVR250 x 2 - GeForce FX 5200 - Onboard sound/NIC 80GB ATA/250GB ATA/400GB SATA


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 12:29 pm 
Offline
Joined: Wed Dec 10, 2003 8:31 pm
Posts: 1996
Location: /dev/null
Unless ntp-server will "hard" sync your clock to the timesever @ boot, I think my cronjob is a nice solution to use in conjunction with ntp-server. I edited the first post to this end.

Thanks to all who replied!

_________________
Retired KM user (R4 - R6.04); friend to LH users.


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu