Airflow DAG 计划延迟一天但手动触发器不是

Airflow DAG scheduled with a day late but manual triggers is not

我使用 Airflow 1.8.0 我有一个像这样的 DAG :

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'email': ['technical@me.com'],
    'start_date': datetime.datetime(2018, 5, 21),
    'email_on_retry': False,
    'retries': 0
}


dag = DAG('my_dag',
          schedule_interval='40 20 * * *',
          catchup=True,
          default_args=default_args)

每天都正确安排了 dag,但晚了一天。

鉴于今天的日期是

2018-07-02

网页界面显示:

而不是2018-07-01

但是如果我手动触发 当前日期已正确传递:

有没有办法强制调度程序使用当前日期运行?

你的 schedule_intervalschedule_interval='20 40 * * *'。请记住,schedule_interval 是 CRON 格式,或 (Minutes Hour Day(month) Month day(week)。因此您当前的计划实际上是不正确的,因为计划程序 cannot 运行 每 40 小时。是否要使其在每 20 小时的第 40 分钟 运行?如果是这样,请尝试 schedule_interval='40 20 * * *'.

此外,如果您希望 运行 最近一天,请将 catchup 设置为 catchup=False。通过这两个修复,它应该可以工作。请参阅此网站以获取更多 CRON 帮助。

这是正确的,是气流设计的一部分。如果你看 here 你会看到解释:

Note that if you run a DAG on a schedule_interval of one day, the run stamped 2016-01-01 will be trigger soon after 2016-01-01T23:59. In other words, the job instance is started once the period it covers has ended.

Let’s Repeat That The scheduler runs your job one schedule_interval AFTER the start date, at the END of the period.