I have a setup with a RPI/VenusOS, which I power on every 6 hours for 15 minutes to sync data between VenusOS and my home automation system. I use a GSM Hat with a PPP internet connection. The problem I faced was that the time was never synced after startup, since it takes a while to start the PPP connection.
This is my solution, any remarks/suggestions?
1. Install ntpdate using:
opkg install ntpdate
By default rdate is installed but as far as I understood rdate uses a protocol that is depreciated and not supported by the majority of NTP servers.
2. Create a file /data/updatetime.sh:
#!/bin/bash sleep 60 #check and set time ntpdate time.google.com
The sleep 60 is to make sure there is enough time to create a PPP internet connection.
3. Make this file executable
chmod 755 /data/updatetime.sh
4. Add to /data/rc.local (runs after VenusOS startup):
nohup /data/updatetime.sh &
Reboot the system.
Richard