Edit July08 by MicRo
RF: (30Oct2008) The documentation for ntpclient says:
On to ntpclient -l. This is actually easy, if you performed and understood the previous steps. Run
which to me implies that you must deliberately run ntpclient in the background when using -l.
The Slug (NSLU2) has buggy timekeeping facilities, which Cisco apparently tried to fix, but didn't do a very good job of fixing. As of January 2008, on an Unslung system, bcrowell observed that the clock was set to 1999 by default, and setting it correctly didn't "stick" across reboots. This causes all kinds of problems with file synchronization, unpacking tarballs, etc. The following is a fix for the problem for Unslung 6.8:
ipkg install ntpclient
Create the file
#!/bin/sh if [ -n "`pidof ntpclient`" ]; then /bin/killall ntpclient 2>/dev/null fi /opt/sbin/adjtimex -t 10000 /opt/bin/ntpclient -s -h pool.ntp.org > /var/log/ntp.log /usr/sbin/hwclock --systohc --utc
1 * * * * root /opt/bin/ntpclient -s -h pool.ntp.org > /var/log/ntp.log && /usr/sbin/hwclock --systohc --utc
chmod +rx /opt/etc/init.d/S10ntpclient
See http://en.wikipedia.org/wiki/Network_Time_Protocol for an explanation of what NTP is.
Documentation for the
The above is an attempt by me (bcrowell) to summarize and organize some previous material. Here are some questions I have. If my understanding of these points is correct, please change them to affirmative statements.
NB: This timer problem has now been fixed in the Openslug & UcSlugC source HEAD.
I've done a bit of work on this. Here's a scheme that keeps the hardware clock in-line, gets an accurate time at boot, and runs the client.
The requisite scripts are provided below. The diversion script edits, rather than replaces, crontab. This will minimize interactions with other users of crontab.
It would be nice if the ntpclient kit were updated with these, but I don't have time at the moment..
Be sure to name and place them exactly as specified. Be sure to delete the leading space from each line. And be sure that you get the very long lines -- without wrapping. [but note: you've spelled rstimezone two different ways! :^)]
Also, remember to:
chmod +x /unslung/rc.rstimezone /unslung/rc.crond /opt/etc/init.d/S10ntpclient
#! /bin/sh # Diversion script to get control of time # # Extract the GUI timezone from the .conf file # Copy the corresponding /usr/zoneinfo file over /usr/local/localtime /usr/sbin/Set_TimeZone >/dev/null # # Adjust the hardware clock for accumulated drift # /usr/sbin/hwclock --adjust # # Initialize the kernel with the corrected time # /usr/sbin/hwclock --hctosys >/dev/null # # ntpclient will (shortly) start correcting the system clock # # The hwclock drift will be computed & recorded once an hour (crontab) # # Do not execute the linksys script # return 0 # EOF - include this line
#! /bin/sh # Diversion script: customize before starting crond # # Reason: change the periodic update of the hwclock to use --adjust # if [ ! -e /etc/crontab.orig ]; then cp -p /etc/crontab /etc/crontab.orig; fi sed -i -e 's/1 \* \* \* \* root \/usr\/sbin\/hwclock -s \&>\/dev\/null/1 \* \* \* \* root \/usr\/sbin\/hwclock --adjust --utc \&>\/dev\/null/' /etc/crontab # # Continue to start crond # return 1 # EOF - include this line
/etc/crontab After editing, it will look like this. The original is saved as crontab.orig.
SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO="" HOME=/ # ---------- ---------- Default is Empty ---------- ---------- # 0 0-23/8 * * * root /usr/sbin/CheckDiskFull &>/dev/null 0 0 * * * root /usr/sbin/WatchDog &>/dev/null 1 * * * * root /usr/sbin/hwclock --adjust --utc &>/dev/null
**** Don't copy crontab to your system; let the script do the edits ****
#!/bin/sh # if [ -n "`pidof ntpclient`" ]; then /bin/killall ntpclient 2>/dev/null fi # # Initialize kernel variables? # #/opt/sbin/adjtimex -t 10000 # # Simple set first. This will abruptly ensure that we are in sync with the server # if the server responds, we'll set the hwclock to match the response # /opt/bin/ntpclient -s -l -h 0.pool.ntp.org > /var/log/ntp.log && hwclock --systohc --utc # # Now start daemon to keep us in sync # /opt/bin/ntpclient -i 600 -l -h 0.pool.ntp.org >> /var/log/ntp.log & # EOF - include this line
Don't forget to set your timezone
Gordon Baskin adds:
#!/bin/sh if [ -n "`pidof ntpclient`" ]; then /bin/killall ntpclient 2>/dev/null fi /opt/sbin/adjtimex -t 10000 >/dev/null /opt/bin/ntpclient -s -h pool.ntp.org > /var/log/ntp.log /usr/sbin/hwclock --systohc --utc
Chong Lee adds: Or you could use the -q flag:
/opt/sbin/adjtimex -q -t 10000
At least for ntpclient version 2007_365-1
view · edit · print · history · Last edited by Chong Lee.
Based on work by Chong Lee, Ralph Finch, RalphFinch, Gordon Baskin, MicRo, JW, tomb, bcrowell, Reedy Boy, an anonymous user of NSLU2-Linux, emm_is, cnczane, blaster8, UncleOp, rob, tlhackque, tman, perlguru, and jbuzbee.
Originally by rwhitby.
Page last modified on January 30, 2009, at 03:55 PM