![]() |
Edit July08 by MicRo 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: Install 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
In 1 * * * * root /opt/bin/ntpclient -s -h pool.ntp.org > /var/log/ntp.log && /usr/sbin/hwclock --systohc --utc Make chmod +rx /opt/etc/init.d/S10ntpclient Run the Explanation:See http://en.wikipedia.org/wiki/Network_Time_Protocol for an explanation of what NTP is. The Documentation for the 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 Enjoy, --tlhackque /unslung/rc.rstimezone#! /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 /unslung/rc.crond#! /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 **** /opt/etc/init.d/S10ntpclient
#!/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 In Debian, Gordon Baskin adds: The file
#!/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
view ·
edit ·
print ·
history ·
Last edited by Gordon Baskin.
Based on work by 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 September 13, 2008, at 10:00 PM
|