NSLU2-Linux
view · edit · print · history

HowTo.FixTheClockUsingOnlyNtpclient History

Hide minor edits - Show changes to markup

April 27, 2009, at 02:48 PM by Kees Moerman --
Changed lines 50-53 from:

What I do instead of running ntpclient as background job, is running a small script basically doing an endless loop containing 'sleep 600', followed by '/var/log/ntpclient -f 0 -s -g 100000 -h nl.pool.ntp.org >>/var/log/ntp.log'. I copied ntpclient to the =RAMdisk?= in /var/log, in order not to wake the hard disk in case it is asleep (see ).

I start this script from a wrapper script in /opt/etc/init.d/S92ntpclient (the script itself does not return, as it contains an endless loop). I use S92 in order to schedule it after the =RAMdisk?= creation (the wrapper also copies the ntpclient executable to the =RAMdisk?=).

to:

What I do instead of running ntpclient as background job, is running a small script basically doing an endless loop containing 'sleep 600', followed by '/var/log/ntpclient -f 0 -s -g 100000 -h nl.pool.ntp.org >>/var/log/ntp.log'. I copied ntpclient to the RAMdisk in /var/log, in order not to wake the hard disk in case it is asleep (see SpinDownUSBHarddisks?).

I start this script from a wrapper script in /opt/etc/init.d/S92ntpclient (the script itself does not return, as it contains an endless loop). I use S92 in order to schedule it after the RAMdisk creation (the wrapper also copies the ntpclient executable to the RAMdisk).

April 27, 2009, at 02:48 PM by Kees Moerman --
Changed lines 50-53 from:

What I do instead of running ntpclient as background job, is running a small script basically doing an endless loop containing 'sleep 600', followed by '/var/log/ntpclient -f 0 -s -g 100000 -h nl.pool.ntp.org >>/var/log/ntp.log'. I copied ntpclient to the RAMdisk? in /var/log, in order not to wake the hard disk in case it is asleep (see SpinDownUSBHarddisks?).

I start this script from a wrapper script in /opt/etc/init.d/S92ntpclient (the script itself does not return, as it contains an endless loop). I use S92 in order to schedule it after the RAMdisk? creation (the wrapper also copies the ntpclient executable to the RAMdisk?).

to:

What I do instead of running ntpclient as background job, is running a small script basically doing an endless loop containing 'sleep 600', followed by '/var/log/ntpclient -f 0 -s -g 100000 -h nl.pool.ntp.org >>/var/log/ntp.log'. I copied ntpclient to the =RAMdisk?= in /var/log, in order not to wake the hard disk in case it is asleep (see ).

I start this script from a wrapper script in /opt/etc/init.d/S92ntpclient (the script itself does not return, as it contains an endless loop). I use S92 in order to schedule it after the =RAMdisk?= creation (the wrapper also copies the ntpclient executable to the =RAMdisk?=).

April 27, 2009, at 02:43 PM by Kees Moerman -- Alternative method of using ntpclient
Changed lines 42-54 from:

This keeps accurate time on my Unslung as compared to an atomic (radio-controlled) clock. It is simpler than explicit use of adjtimex but still corrects the drift using that feature of ntpclient.

to:

This keeps accurate time on my Unslung as compared to an atomic (radio-controlled) clock. It is simpler than explicit use of adjtimex but still corrects the drift using that feature of ntpclient.


Alternate method based on ntpclient

Unfortunately, the above method does not work correctly for me. Somehow, ntpclient gives up after some time, with the '# inconsistent' message in the log file. Difficult to find good information on what to change to circumvent this message (my clock is too irregular?).

What I do instead of running ntpclient as background job, is running a small script basically doing an endless loop containing 'sleep 600', followed by '/var/log/ntpclient -f 0 -s -g 100000 -h nl.pool.ntp.org >>/var/log/ntp.log'. I copied ntpclient to the RAMdisk? in /var/log, in order not to wake the hard disk in case it is asleep (see SpinDownUSBHarddisks?).

I start this script from a wrapper script in /opt/etc/init.d/S92ntpclient (the script itself does not return, as it contains an endless loop). I use S92 in order to schedule it after the RAMdisk? creation (the wrapper also copies the ntpclient executable to the RAMdisk?).

Is this an appropriate solution, or are there better ideas?

November 22, 2008, at 01:13 AM by SamiT --
Added lines 1-4:

Running ntpclient in the background from init.d scripts doesn't require nohup and only one '&' is needed. I changed those.

SamiT?.

Changed line 31 from:

nohup /opt/bin/ntpclient -f 0 -s -l -i 600 -g 10000 -h pool.ntp.org >> /var/log/ntp.log &&

to:

/opt/bin/ntpclient -f 0 -s -l -i 600 -g 10000 -h pool.ntp.org >> /var/log/ntp.log &

November 03, 2008, at 03:01 PM by RFinch --
Changed lines 13-14 from:

http://doolittle.icarus.com/ntpclient/HOWTO

to:

http://doolittle.icarus.com/ntpclient/HOWTO

November 03, 2008, at 03:01 PM by RFinch --
Changed lines 13-14 from:

[http://doolittle.icarus.com/ntpclient/HOWTO]

to:

http://doolittle.icarus.com/ntpclient/HOWTO

November 03, 2008, at 03:00 PM by RFinch --
Changed lines 13-14 from:

http://doolittle.icarus.com/ntpclient/HOWTO

to:

[http://doolittle.icarus.com/ntpclient/HOWTO]

November 03, 2008, at 03:00 PM by RFinch --
Changed lines 12-14 from:

This is what I use then, following the advice in http://doolittle.icarus.com/ntpclient/HOWTO

to:

This is what I use then, following the advice in http://doolittle.icarus.com/ntpclient/HOWTO

November 03, 2008, at 02:58 PM by RFinch --
Changed lines 36-38 from:

automatically every time you reboot.

to:

automatically every time you reboot.

This keeps accurate time on my Unslung as compared to an atomic (radio-controlled) clock. It is simpler than explicit use of adjtimex but still corrects the drift using that feature of ntpclient.

November 03, 2008, at 02:52 PM by RFinch --
Changed lines 27-28 from:

nohup /opt/bin/ntpclient -f 0 -s -l -i 600 -g 10000 -h pool.ntp.org >> /var/log/ntp.log &&

to:

nohup /opt/bin/ntpclient -f 0 -s -l -i 600 -g 10000 -h pool.ntp.org >> /var/log/ntp.log &&

November 03, 2008, at 02:49 PM by RFinch -- How to fix the clock using ntpclient correctly
Added lines 1-37:

How to Fix the Clock using Only ntpclient (correctly)

The documentation for ntpclient says:

On to ntpclient -l. This is actually easy, if you performed and understood the previous steps. Run
     ntpclient -l -h $NTPHOST
in the background.

which to me implies that you must deliberately run ntpclient in the background when using -l.

This is what I use then, following the advice in http://doolittle.icarus.com/ntpclient/HOWTO

Install ntpclient:

ipkg install ntpclient

Create the file /opt/etc/init.d/S10ntpclient containing the following:

#!/bin/sh
if [ -n "`pidof ntpclient`" ]; then
/bin/killall ntpclient 2>/dev/null
fi
nohup /opt/bin/ntpclient -f 0 -s -l -i 600 -g 10000 -h pool.ntp.org >>
/var/log/ntp.log &&

In /etc/crontab , delete the line containing hwclock.

Make /opt/etc/init.d/S10ntpclient script executable: chmod +rx /opt/etc/init.d/S10ntpclient

Run the S10ntpclient script once by hand, and then it will run automatically every time you reboot.

view · edit · print · history · Last edited by Kees Moerman.
Based on work by Kees Moerman, SamiT, and RFinch.
Originally by RFinch.
Page last modified on April 27, 2009, at 02:48 PM