How to create schedules
Learn how to create schedules for your deployments.
There are several ways to create a schedule for a deployment:
- Through the Prefect UI
- With the
cron
,interval
, orrrule
parameters if building your deployment with theserve
method of theFlow
object or theserve
utility for managing multiple flows simultaneously - If using worker-based deployments
- When you define a deployment with
flow.serve
orflow.deploy
- Through the interactive
prefect deploy
command - With the
deployments
->schedules
section of theprefect.yaml
file
- When you define a deployment with
Create schedules in the UI
You can add schedules in the Schedules section of a Deployment page in the UI. To add a schedule select the + Schedule button. Choose Interval or Cron to create a schedule.
What about RRule? The UI does not support creating RRule schedules. However, the UI will display RRule schedules that you’ve created through the command line.
The new schedule appears on the Deployment page where you created it. New scheduled flow runs are visible in the Upcoming tab of the Deployment page.
To edit an existing schedule, select Edit from the three-dot menu next to a schedule on a Deployment page.
Create schedules in Python
Specify the schedule when you create a deployment in a Python file with flow.serve()
, serve
, flow.deploy()
, or deploy
.
Just add the keyword argument cron
, interval
, or rrule
.
Argument | Description |
---|---|
interval | An interval on which to execute the deployment. Accepts a number or a timedelta object to create a single schedule. If a number is given, it is interpreted as seconds. Also accepts an iterable of numbers or timedelta to create multiple schedules. |
cron | A cron schedule string of when to execute runs of this deployment. Also accepts an iterable of cron schedule strings to create multiple schedules. |
rrule | An rrule schedule string of when to execute runs of this deployment. Also accepts an iterable of rrule schedule strings to create multiple schedules. |
schedules | A list of schedule objects defining when to execute runs of this deployment. Used to define multiple schedules or additional scheduling options such as timezone . |
schedule | A schedule object defining when to execute runs of this deployment. Used to define additional scheduling options such as timezone . |
slug | An optional unique identifier for the schedule containing only lowercase letters, numbers, and hyphens. If not provided for a given schedule, the schedule will be unnamed. |
The serve
method below will create a deployment of my_flow
with a cron schedule that creates runs every minute of every day:
If using deployments with dynamic infrastructure, the deploy
method has the same schedule-based parameters.
When my_flow
is served with this interval schedule, it will run every 10 minutes beginning at midnight on January, 1, 2026 in the America/Chicago
timezone:
Create schedules with the CLI
You can create a schedule through the interactive prefect deploy
command. You will be prompted to choose which type of schedule to create.
Create schedules in YAML
If you save the prefect.yaml
file from the prefect deploy
command, you will see it has a schedules
section for your deployment.
Alternatively, you can create a prefect.yaml
file from a recipe or from scratch and add a schedules
section to it.
Create schedules with Terraform
You can manage schedules with the Terraform provider for Prefect.
Associate parameters with schedules
Using any of the above methods to create a schedule, you can bind parameters to your schedules.
For example, say you have a flow that sends an email. Every day at 8:00 AM you want to send a message to one recipient, and at 8:05 AM you want to send a different message to another recipient.
Instead of creating independent deployments with different default parameters and schedules, you can bind parameters to the schedules themselves:
Schedule parameters in Python
Whether using .serve
or .deploy
, you can pass parameters
to your deployment schedules
:
Note that our flow has a default message
parameter, but we’ve overridden it for the second schedule.
This deployment will schedule runs that:
- Send “Stop goofing off!” to Jim at 8:00 AM every day
- Send “Stop goofing off! You’re assistant to the regional manager!” to Dwight at 8:05 AM every day
Use the same pattern to bind parameters to any schedule type in prefect.schedules
.
You can provide one schedule via the schedule
kwarg or multiple schedules via schedules
.
Schedule parameters in prefect.yaml
You can also provide parameters to schedules in your prefect.yaml
file.