Hui Wu
04/16/2026, 6:21 PMMarvin
04/16/2026, 6:21 PMMarvin
04/16/2026, 6:24 PMDTSTART= for the start
- UNTIL= for the end
Example in prefect.yaml:
deployments:
- name: my-deployment
schedules:
- rrule: "DTSTART=20240701T090000Z;RRULE:FREQ=DAILY;UNTIL=20240731T235959Z"
timezone: "America/New_York"
For “only between certain hours each day,” you can constrain hours too:
rrule: "RRULE:FREQ=MINUTELY;INTERVAL=5;BYHOUR=9,10,11,12,13,14,15,16"
Or via cron, restrict hours (e.g., every 5 min 9–16h, weekdays):
cron: "*/5 9-16 * * 1-5"
- Pause/resume schedules: Use the UI or CLI to pause at a start time and resume at an end time (manually or via Automations)
- Pause a specific schedule:
prefect deployment schedule pause my-flow/my-deployment <schedule-id>
- Resume a specific schedule:
prefect deployment schedule resume my-flow/my-deployment <schedule-id>
- Automations can be set up to pause/resume at specific timestamps.
If you can share whether you need a single bounded window (between two dates) or recurring daily windows (e.g., 9am–5pm), I can give you the exact config that fits best.Hui Wu
04/16/2026, 6:40 PMMarvin
04/16/2026, 6:40 PMMarvin
04/16/2026, 6:43 PMimport asyncio
from prefect.client import get_client
async def show_next_runs(deployment_name: str, limit: int = 10):
async with get_client() as client:
dep = await client.read_deployment_by_name(deployment_name)
runs = await client.get_scheduled_flow_runs_for_deployments(
deployment_ids=[dep.id],
limit=limit,
)
print(f"Next {len(runs)} scheduled runs for {deployment_name}:")
for r in runs:
print(f"- {r.next_scheduled_start_time} (run_id={r.id})")
asyncio.run(show_next_runs("my-flow/my-deployment"))
Key notes:
- next_scheduled_start_time is the correct field to display the “next runtime.”
- This returns runs the Prefect scheduler has already created (what you’ll also see in the UI’s “Upcoming” list).
- There isn’t a public SDK method that “predicts” times directly from a schedule object; for local previews, use standard libs like croniter (cron) or dateutil.rrule (RRULE).