Frustrated by openwrt booting up with wildly obsolete time, causing certain time-sensitive apps to break upon restart, I finally tracked down /etc/init.d/sysfixtime, which reportedly sets the openwrt syste clock using the timestamp of the newest file in /etc to a "reasonably" approximate time, on hardware that has no RTC or battery for time-keeping.
A gander in / shows it is probably the "best" approach. However, it is still not good enough for my hardware that has no hardware clock or battery. Even though mine is plugged into a UPS, sys time after reboot is still often wildly off, I guess because my /etc doesn't get changed THAT often.
I have been manually executing "ntpd -qnN -p [ip-addr-of-some-ntp-server]" to force-adjust systime after reboot, in order for the affected apps to start up correctly. I'm wondering what the best approach is to automate this:
- Append the ntpd commands in /etc/init.d/sysfixtime? I realize this assumes internet or LAN network access, while checking /etc doesn't. Is ntpd likely to be removed from the default openwrt (base?) install in the future?
- Use a shutdown script to write an empty file in /etc? Or, is there a better approach?
Changed /etc/init.d/sysfixtime would get overwriten by new openwrt (snapshots) installs, so it doesn't cover that scenario. Can shutdown script be preserved in /etc/sysupgrade.conf and survive new openwrt snapshot install?
Are there any other approaches?