Changing date/time on the device



How would I go about changing the system date from inside my container? I have a lot of time-dependent code, and changing the system time is the easiest way to test things.

date -s "27 OCT 2017 7:44:00" doesn’t persist.



Hi, the devices are running the NTP service (systemd-timesync) to set up the correct time. I’m guessing that time syncing is the part that doesn’t make your changes stick.

Just tried it out, and in the host OS, I see in the logs I can see the systemd[1]: Time has been changed entries that resets to the correct time after issuing the command you posted.

If you need to test with setting the time, would suggest the following:

  • use the .dev version of resinOS for your development, which opens up the system more
  • when you have the .dev, you can log into the host OS using the resin-cli: for example resin local ssh --host <IP>
  • stop the time synchronization (with systemctl stop systemd-timesyncd)
  • do your time manipulation inside the user container as you’ve mentioned… :mantelpiece_clock:

Some extra notes: this will work only on your local network (due to the the resin local ssh); and do not use .dev devices in production, they are open access by default, only for development; changing the time might have effect on other parts of the system which is good to keep in mind when debugging.

Hope this helps!


Working great, thanks!