Update VM's date with Flyio ssh console

Hi everyone.

When I try to change the date of my app’s vm with date -s “yyyy-mm-dd hh:mm:ss” it’s overriden once I logout of the server.

example: date -s “2023-04-11 10:30:00”.

How can I change/persists the vm’s date?

Thank you.

Maybe the date is being reset when the VM restarts?

You could change the date from the startup command (experimental.cmd / processes) to apply the change when the VM restarts.

But depending on what you’re actually trying to achieve, there may a better way. For example if you just want to change the timezone, there are cleaner ways.

1 Like

Thank you Tom.

The problem is that my app is taking the current date from the server. But the date is wrong besides the timezone is for Miami, FL (the same as mine). Yesterday was April, 10th but the server’s date was April 11th.

So I need to correct the date of the server in order to get my app’s record being persisted for my current date.

How can I do that? (I did it with the command flyio ssh console, then executed the date command)

Huh. That sounds like an issue that Fly should fix. In the meantime, here is a hack (based on How do I set time and date from the Internet?):

date -s "$(wget --method=HEAD -qSO- --max-redirect=0 https://www.google.com 2>&1 | sed -n "s/^ *Date: *//p")"

Put this in your startup command. For example, if you are using Nomad (Apps V1, see docs), use the following in fly.toml:

  cmd = 'date -s "$(wget --method=HEAD -qSO- --max-redirect=0 https://www.google.com 2>&1 | sed -n "s/^ *Date: *//p")" && ORIG_CMD'

Replace ORIG_CMD with your app’s original startup command. I’m not sure what’s the best way to find out what it was. Maybe look for the line “Preparing to run:” in the output of fly logs; but note that this line is a combination of the (optional) entrypoint and cmd, and you only need the cmd.

1 Like

Hmm, that’s unexpected. I just tried spinning up an app to see if I could reproduce but it looks like it has the accurate time. What are you seeing when you run date?

1 Like


This is the current log. Look it says 20 hours so within 4 it will change the date.

Thank you

Thanks for the screenshot. The “Miami, Florida” dropdown is for filtering logs by region which region they’re in. It’s not a timezone adjustment. The log messages are shown in UTC (which is 4 hours ahead of Miami) so that’s why you’re seeing a different day than you expect.


I think @benbjohnson cracked it. Small additional clarification:

The format of the time in the logs is hh:mm:ss, so 2023-04-11T00:20:20.046 is actually a little after midnight on the 11th (UTC).

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.