我想尝试使用Airflow代替Cron。 但是schedule_interval不能按我预期的那样工作。
I want to try to use Airflow instead of Cron. But schedule_interval doesn't work as I expected.
我写了如下的python代码。 在我的理解中,Airflow应该在 2016/03/30 8:15:00上运行,但当时不起作用。
I wrote the python code like below. And in my understanding, Airflow should have ran on "2016/03/30 8:15:00" but it didn't work at that time.
我想,如果我将其更改为'schedule_interval':timedelta(minutes = 5),则它可以正常工作。
If I changed it like this "'schedule_interval': timedelta(minutes = 5)", it worked correctly, I think.
notice_slack.sh仅是为了向我的频道调用松弛api。
The "notice_slack.sh" is just to call slack api to my channels.
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import os from airflow.operators import BashOperator from airflow.models import DAG from datetime import datetime, timedelta args = { 'owner': 'airflow', 'depends_on_past': False, 'start_date': datetime(2016, 3, 29, 8, 15), } dag = DAG( dag_id='notice_slack', default_args=args, schedule_interval="@daily", dagrun_timeout=timedelta(minutes=1)) # cmd file name CMD = '/tmp/notice_slack.sh' run_this = BashOperator( task_id='run_transport', bash_command=CMD, dag=dag)<我想在s上运行一些脚本
I want to run some of my scripts at specific time every day like this cron setting.
15 08 * * * bash /tmp/notice_slack.sh我已阅读文档计划和触发器,我知道它的cron有点不同。 因此,我尝试安排 start_date和 schedule_interval设置。
I have read the document Scheduling & Triggers, and I know it's a little bit different cron. So I attempt to arrange at "start_date" and "schedule_interval" settings.
有人知道我应该怎么做吗?
Does anyone know what should I do ?
气流版本
airflow version
信息-使用执行程序LocalExecutor
INFO - Using executor LocalExecutor
v1.7.0
amazon-linux-ami / 2015.09-release-notes
amazon-linux-ami/2015.09-release-notes
推荐答案
当以下情况时,气流将启动DAG通过了2016/03/30 8:15:00 +计划间隔(每天)。因此,您的DAG将于2016/03/31 8:15:00运行。
Airflow will start your DAG when the 2016/03/30 8:15:00 + schedule interval (daily) is passed. So your DAG will run on 2016/03/31 8:15:00.
您可以检查气流常见问题解答
更多推荐
如何正常工作气流schedule
发布评论