LinHES Forums http://forum.linhes.org/ |
|
Howto: have your system time sync'ed with server every 4 h http://forum.linhes.org/viewtopic.php?f=11&t=14344 |
Page 1 of 1 |
Author: | graysky [ Sun Feb 25, 2007 4:40 am ] |
Post subject: | Howto: have your system time sync'ed with server every 4 h |
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). |
Author: | tjc [ Sun Feb 25, 2007 9:38 am ] |
Post subject: | |
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. |
Author: | graysky [ Fri Mar 02, 2007 3:23 pm ] |
Post subject: | |
As always, thanks for the info, tjc. How does ntpserver sync the clock differently then a manual (or cron job) of ntp-date? |
Author: | tjc [ Fri Mar 02, 2007 8:59 pm ] |
Post subject: | |
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... |
Author: | graysky [ Mon Mar 05, 2007 3:01 pm ] |
Post subject: | |
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)? |
Author: | khrusher [ Tue Mar 06, 2007 7:55 am ] |
Post subject: | |
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 |
Author: | graysky [ Tue Mar 06, 2007 12:29 pm ] |
Post subject: | |
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! |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |