I’m using a BeagleBone, and since it has no built in RTC and battery back up, it loses the date on every reboot. I can easily set the date with the command:
/usr/bin/ntpdate -b -s -u pool.ntp.org
But if the power goes out and back on for the house for example, then the time is lost. The solution that comes with the latest beaglebone Angstrom linux distribution is to put a crontab line in that updates the time every half hour. But I would prefer to just run the command once on powerup.
I tried putting this command listed above in crontab with the @reboot line, but that I believe ran before network was configured, or something else failed since it didn’t get me the right time when I pulled the power for 5 minutes and put it back to the beaglebone.
Is there some way to use ifconfig or something like that to run a script from init.d only after network is available?
Edit /etc/ntp.conf and comment the following lines (no fallback on an hardware clock that doesn’t exist and because the ntpdate service use the “ntpd -q” command)
Two services are installed:
/lib/systemd/system/ntpd.service:
/lib/systemd/system/ntpdate.service:
ntpd is started after the network is up (After=network.target) so the date should be continuously synchronized. BUT has explained in the ntpd man page:
So we need to set the date before starting ntpd and this is done by the ntpdate service by executing “ntpd -q -g -x” before starting ntpd.service.
From ntpd man page:
Another service installed on the Beaglebone interact with the date/time
timestamp.service
This service store the current timestamp in /etc/timestamp when it’s stopped and set the date from that timestamp when it’s started. So if ntpd isn’t installed, the date set manually and the beaglebone rebooted, the date is only behind by the boot duration.