New feature: Scheduled machines

Is it possible to schedule a custom interval like every 2 days? Or only: "monthly", "weekly", "daily", "hourly" is allowed?

@rngrnginf right now we have no plans to offer that level of customization, maybe a potential workaround could be to have whatever process you’re running detect last execution and exit immediately if no work needs to be done? Then it’d be possible to use the daily interval.

1 Like

Ahh, cool idea:D will do this! thanks @JP_Phillips :grinning:!

Even after having a look at all the posts in this thread I could not successfully use this. Is there any link with a step by step guide? I am fairly new with fly and have no background with schedulers

This comment didn’t help? I don’t see a step-by-step guide for schedulers in Fly docs, but ref this official guide on using Machines with flyctl (forum post).

The scheduler part of it simply amounts to appending --schedule=[hourly|daily|weekly] switch to flyctl machine [run|update] commands.


In general, to know more about Fly, start here: Fly.io Reference Guide · Fly Docs

Thanks a lot for your quick reply. I am just really confused about the whole concept of Machines to be honest. I now feel like what i want is compeletly different to the purpose of this.

What I want to do is run a script every night to update my database data. I followed the steps you mentioned. I created a new NodeJS app. Created a machine from that. How do i specify which script to run on schedule? I understand that i need to use that command but how to i connect my script?

A single-process Machine runs an entrypoint / cmd as defined in the app’s dockerfile or its fly.toml (docs).

One can choose to run a different entrypoint / cmd by specifying a fly m run --entrypoint <here> [--schedule daily] ... but I am not sure if it works for scheduled Machines; you could give that a shot and let us know if it does.

The usual way: Whatever script you want run every day should be the dockerfile / fly.toml entrypoint / cmd instead.

If you want cron-style jobs, however, there’s a couple of ways to do this (superchronic, crontab with apps v1 not machines).

In general, to understand what a Machine (apps v2) is, see if this answer helps: Advantages/Disadvantages of Machine Apps - #2 by fideloper-fly

I’m trying this out for a periodic synchronization job that runs daily with an attached volume for persistent storage. Unfortunately it looks like after the application is initialized, the main process exits and the attached volume unmounts and does not remount before the next job starts. Is this expected behaviour? Would anyone have suggestions for an optimal way to ensure the volume is attached upon the next scheduled job starting? The behaviour I’m ideally looking for is that the machine is suspended between jobs (to avoid being wasteful with resources) so it would be nice to avoid having a long running process to keep the volume mounted

Can this update an app by pulling the latest image tag daily? What I want is for my app to keep running but update to the latest tag daily.

Forgive me for this novice question but when you indicate that these wake periods can be scheduled daily, is there a time or a manner to set a time?

For instance I have a job that is scheduled to run every day at 0830, I’d like to have my machine awoken at 0815 and stay awake until at least 0845.