su ntpdate -b -s -u pool.ntp.orgThis works fine, but I keep forgetting to do it, then I get ridiculous timestamps on my files, make complains about clock skew, and I am generally annoyed.
And the BBB has no handy rc.local file, which would be a perfect place to put the above command as a quick and easy solution. Apparently some pinhead somewhere decided that there was something evil about rc.local and wants to force us all to deal with systemd.
It turns out that the ntpdate "one time" service is indeed a proper thing on a system like the BBB without a hardware clock. My regular desktop linux (fedora) systems do not have an ntpdate service. They do have some kind of reasonable battery clock - so they have a half-way decent time right after boot. This is not true of the BBB which thinks it is Jan 1, 2000 after every boot. It turns out that ntp will refuse to adjust the time (unless a special switch is given) if the time error is too great.
su systemctl enable ntpdate.service systemctl start ntpdate.service rebootTo all appearances this does nothing, but you have to be patient as it turns out. Even after the reboot, the time is January 1, 2000. And if you look at the logs using the following command, you see the following error:
journalctl | grep ntp Can't find host pool.ntp.org: Name or service not known (-2)This looks like one of the usual dependency issues that plague systemd. It is trying to do the first time sync before the network is up, or something like that. However if you wait a while, voila! Apparently the ntpdate.service tries again later and is able to get a time sync.
The next thing to do is to set the timezone. I am in Arizona which has special rules (it is MST without daylight savings time). When I look in /usr/share/zoneinfo/America (and elsewhere) there is no rule that is correct for Arizona. What I do is to copy an Arizona entry from a Fedora linux system and put it in /usr/share/zoneinfo/America/Arizona (and cross my fingers). Then:
su cd /etc echo "Arizona" >timezone rm localtime ln -s /usr/share/zoneinfo/America/Arizona localtimeAfter this I can type "date" and I am getting the correct time. And it works just fine after a reboot (it is now keeping the time across a boot and making a correction later, or something like that).
If you are really curious, take a look at:
opkg update opkg install ntp
systemctl enable ntpd.service systemctl enable ntpdate.serviceThen I edit the file /lib/systemd/system/ntpdate.service and change one line to two:
ExecStart=/usr/bin/ntpdate-sync silent - change to: ... ExecStart=/usr/bin/ntpd -q -g -x ExecStart=/sbin/hwclock --systohcI found that this was not working. And some investigation revealed that the ntpdate service was in conflict with the ntpd service (both trying to use port 123), so I disabled ntpdate. Things still do not work. Very confusing -- not to mention irritating.
Tom's Computer Info / tom@mmto.org