<@ULVA73B9P> how can i schedule a flow to run ever...
# ask-community
m
@Marvin how can i schedule a flow to run every minute but at 5th second of minute
m
thought for 486.5 seconds
Assuming Prefect 3.x, you’ve got two good options: 1) Cron (6 fields; seconds first) - Expression:
5 * * * * *
→ runs at the 5th second of every minute - CLI:
Copy code
prefect deployment schedule create <deployment-name> --cron "5 * * * * *" --timezone "UTC"
- Python:
Copy code
from prefect import flow
from prefect.schedules import Cron

@flow
def my_flow():
    ...

my_flow.serve(
    name="every-minute-at-5s",
    schedule=Cron("5 * * * * *", timezone="UTC")
)
2) RRule (explicit seconds) - Expression:
FREQ=MINUTELY;BYSECOND=5
- CLI:
Copy code
prefect deployment schedule create <deployment-name> --rrule "FREQ=MINUTELY;BYSECOND=5" --timezone "UTC"
- Python:
Copy code
from prefect import flow
from prefect.schedules import RRule

@flow
def my_flow():
    ...

my_flow.serve(
    name="every-minute-at-5s",
    schedule=RRule("FREQ=MINUTELY;BYSECOND=5", timezone="UTC")
)
Notes: - With cron in Prefect (via croniter), the 6-field format is “second minute hour day month day_of_week”, so
5 * * * * *
means “at second 5 of every minute.” - Add
--timezone
(or
timezone=
in Python) if you need a specific TZ. Do you already have a deployment created, or would you like an example using
flow.from_source(...).deploy(...)
with schedules?
m
I tried cron="* * * * * 5" and it scheduled jobs correctly at 5th second of every minute instead of "5 * * * * *" but on prefect ui it shows the wrong text Every second, only on Friday
n
wait sorry, are you trying to do
* * * * * 5
or
5 * * * * *
? i thought it was the latter but then you said
I tried cron="* * * * * 5"