wake-on-schedule instead of wake-on-request?

Hi all,

Is it possible to have my (Docker) app be run on a machine that wakes on a schedule, rather than a request? I’d like for Fly to run my app, say, once every 3 hours, then let it exit.

How can I do that?

Thanks,
Matthew

For cron-like flexibility, the setup is a bit more involved: Crontab with Supercronic · Fly Docs

With Scheduled Machines, one can only specify monthly, daily, or hourly intervals: New feature: Scheduled machines

One can also wake-up their Machine periodically by sending http reqs from an external service like Durable Object Alarms.

Ref: Recurring scheduled tasks (like cron)

It looks like daily scheduled machines will work for me. My app is a dockerized python script that exits after it performs its task, very much like a cloud function.

Is that how the app is expected to behave in a scheduled machine?

1 Like

Pretty much yes; sys.exit(0) should settle the scheduled machine.

Ok machine created with --schedule=daily. Shows as stopped.

I would have expected it to run my script (packaged in my docker image) upon deployment once, then wait 24h before running again. Does it only run after 24h?

I vaguely remember that this was indeed the behaviour. Not sure what changed (or if things have been this way since the beginning). May be @shugel knows…

What’s the correct fly command to upgrade the existing scheduled machine with a newer version of the Docker image?

fly deploy should just work and update all Machines of the app (ref). If not, there’s fly m update:

Yep, the last time I deployed a new / updated image, it ran immediately.

1 Like

From How To to Questions / Help

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