You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Airflow每月1号调度DAG的start_date与schedule_interval配置咨询

Airflow DAG 定时配置方案

核心配置代码

from datetime import datetime
from airflow import DAG

default_args = {
    # 固定设置为2020年12月1日UTC时间5点
    "start_date": datetime(2020, 12, 1, 5, tzinfo="UTC"),
}

dag = DAG(
    dag_id="your_target_dag_id",
    default_args=default_args,
    # Cron表达式对应UTC时间每月1日凌晨5点
    schedule_interval="0 5 1 * *",
    # 不需要回溯历史运行时可设为False,避免生成多余历史任务
    catchup=False
)

参数说明

  • schedule_interval 参数:设置为Cron表达式 0 5 1 * *,完全匹配你要求的每月1日UTC凌晨5点的执行周期规则。
  • start_date 参数:设置为 datetime(2020, 12, 1, 5, tzinfo="UTC"),符合Airflow的调度逻辑:
    Airflow的首次运行触发时间为 start_date + schedule_interval,触发时的execution_date为对应调度周期的起始时间。你需要首次触发时间为2021年1月1日5点,且execution_date为2021年1月1日,倒推一个月的调度周期,得到start_date为2020年12月1日5点即可满足要求。

注意事项

  • 禁止将start_date设置为动态时间(比如datetime.now()),会导致调度逻辑混乱,必须使用固定静态时间
  • 如果需要回溯2021年1月1日前的历史运行,可将catchup设置为True,否则保持False即可

内容的提问来源于stack exchange,提问作者Infinite

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 01:18:03