How can I attach a schedule to a flow?

Prefect 2.0

The easiest is to do it from the UI:

But you can also set a schedule in your deployment build step. Check the Discourse FAQ pointing you to the relevant Deployment-related resources:

Prefect 1.0

You attach the schedule to your Flow object:

from prefect import Flow
from prefect.schedules import IntervalSchedule

schedule = IntervalSchedule(interval=timedelta(minutes=15))

with Flow("scheduled_flow", schedule=schedule) as flow:

Additionally, you can test the schedule by printing the next schedules as follows:

from prefect.schedules import IntervalSchedule

schedule = IntervalSchedule(interval=timedelta(minutes=15))

for sched in

Hello! Apologies if I’m missing something - I havent found an answer in any other threads. I am using Prefect 1.0 and I set an IntervalSchedule for my flow similar to the above example.
However, when I register the flow on our internal Prefect Server , the schedule only seems to generate the next 10 events.
I expected that setting IntervalSchedule(interval=timedelta(hours=1)) would make the server continue to schedule hourly events indefinitely. Is there some syntax that I am missing?
I appreciate any help.

this is expected, nothing to worry about, the next runs will be created in the future

Thank you for the quick response!

It turned out to actually be an issue with our service configuration.

Specifically, we found an API error in the towel service logs when it tried to communicate with the HasuraClient. Towel did not have the right port configured for hasura. Once that environment variable was set and fixed, we restarted the service.
I can now see a consistent 10 upcoming runs → each time one executes, another is added by the server.

1 Like

nice work! thx for the update