4.18. Updating the Time at Boot
Problem
You have one of those newfangled routerboards that doesn't have a CMOS battery. BIOS settings are written to nonvolatile RAM, but the time and date are lost with every power-cycle. How do you make it set the time correctly at boot?
Solution
With good ole ntpdate. First, edit /etc/default/ntp-servers so that it points to pool.ntp.org:
# /sbin/rw
# nano /etc/default/ntp-servers
NTPSERVERS="pool.ntp.org"Then create a startup link so it will run at boot:
# ln /etc/init.d/ntpdate /etc/rc2.d/S90ntpdateNow every time you boot up your routerboard, it will set the correct time. You can verify this with the date command:
# date
Mon Jan 29 20:52:50 UTC 2007Discussion
If you are familiar with the NTP documentation, you're aware
that the fine NTP folks keep trying to get rid of
ntpdate and replace it with the nptd-g command. However,
ntpdate still works best for large time
corrections.
See Also
man 1 ntpdateChapter 19, "Keeping Time with NTP," in Linux Cookbook, by Carla Schroder (O'Reilly)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access