pioneers / runtime

Firmware for the PiE kit robots and devices
7 stars 2 forks source link

[MISC][SYSTEMD] Update Raspberry Pi date and time on startup #220

Closed levincent06 closed 3 years ago

levincent06 commented 3 years ago

During Spring Comp 2021, we've found that the clock on Raspberry Pis get unsynced when connected to CalVisitor+Motherbase. (The clock can be behind by days.) This becomes a problem for having accurate timestamps on logs and possible network issues that require synced times.

Below is a one-line command that will update the clock to the current time automatically. Perhaps we can add this to a systemd service so that this runs every time the Raspberry Pi boots up.

sudo date -s "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')"