Update time #258
-
Hey everyone, I've got a cronjob that's set to run daily at 18:00, but with the recent switch to summer time in my country, the schedule's been thrown off by an hour. Now it's running an hour later than I want it to. I'm using a gokrazy instance, and I'm wondering how I can sync up the schedule with the time change automatically. Ideally, I'd like it to adjust itself again when we switch back to standard time and lose that extra hour. Any ideas on how to tackle this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
When you say “cronjob”, do you mean a program running on gokrazy? The gokrazy packer copies /etc/localtime from the host to the instance, so as long as you create the instance on a computer with the desired time zone configured, the default time zone on the gokrazy instance should match what you want. That said, you can always make your Go programs work in any environment (regardless of its default timezone) and use the desired time zone explicitly. For example, to schedule tasks in Zürich time, I use: loc, err := time.LoadLocation("Europe/Zurich")
if err != nil {
panic(err)
} And then, when I need the current time, I use |
Beta Was this translation helpful? Give feedback.
When you say “cronjob”, do you mean a program running on gokrazy?
The gokrazy packer copies /etc/localtime from the host to the instance, so as long as you create the instance on a computer with the desired time zone configured, the default time zone on the gokrazy instance should match what you want.
That said, you can always make your Go programs work in any environment (regardless of its default timezone) and use the desired time zone explicitly. For example, to schedule tasks in Zürich time, I use:
And then, when I need the current time, I use
time.Now().In(loc)