Piotr
07/16/2025, 6:17 AMMarvin
07/16/2025, 6:17 AMMarvin
07/16/2025, 6:18 AMpython
from prefect import flow
from prefect.schedules import Cron
@flow
def my_flow():
print("Running flow!")
# Create deployment with timezone-aware cron
deployment = my_flow.to_deployment(
name="my-scheduled-deployment",
schedule=Cron(
cron="0 9 * * *", # Runs at 9 AM in the specified timezone
timezone="America/New_York" # Specify your desired timezone
)
)
# Deploy the deployment
deployment.deploy()
Key points:
- Use the timezone
parameter in the Cron
class constructor
- Timezone should be specified in IANA tzdata format (e.g., "America/New_York", "Europe/London", "Asia/Tokyo")
- The schedule will automatically handle Daylight Savings Time adjustments if applicable
- If no timezone is specified, the system default timezone will be used
Common timezone examples:
- America/New_York
- America/Los_Angeles
- Europe/London
- Asia/Tokyo
- UTC
You can find a complete list of valid timezone names in the IANA Time Zone Database.
Since you're using a self-hosted Prefect server deployed via Helm chart, make sure your server's timezone settings are properly configured if you want the server's local time to match your expectations.