Python 如何检查针对特定DAG的下一次气流DAG运行计划何时完成?
我已经设置了气流并运行了一些DAG,计划每天运行一次“0***”Python 如何检查针对特定DAG的下一次气流DAG运行计划何时完成?,python,scheduled-tasks,airflow,Python,Scheduled Tasks,Airflow,我已经设置了气流并运行了一些DAG,计划每天运行一次“0***” 我想检查下一次计划运行特定dag的时间是什么时候,但我看不出在管理员中可以在哪里执行该操作。如果您想在内部获取此信息,可以使用jinja{{next_execution_date}但如果您只是想知道dag下一次运行的时间,您可以将时间间隔添加到上次运行的时间间隔中 比如说 从下图 计划间隔为15分钟,最后一次运行时间为2018-09-07 08:32,因此下一次运行时间恰好为15分钟后,即2018-09-07 08:47如果要使
我想检查下一次计划运行特定dag的时间是什么时候,但我看不出在管理员中可以在哪里执行该操作。如果您想在内部获取此信息,可以使用jinja
{{next_execution_date}
但如果您只是想知道dag下一次运行的时间,您可以将时间间隔添加到上次运行的时间间隔中
比如说
从下图
计划间隔为15分钟,最后一次运行时间为2018-09-07 08:32,因此下一次运行时间恰好为15分钟后,即2018-09-07 08:47如果要使用
气流CLI
,则
获取DAG的下一个执行日期时间
airflow next_execution [-h] [-sd SUBDIR] dag_id
更新-1
如果需要以编程方式(在任务中)执行此操作,可以参考
- 的
- (现在移至中的)
更新-2
要不仅获取下一个执行日期,还要获取下一个执行日期,请参阅airflow 2.0.0版中的,在命令行中可以找到下一个执行日期
dags下一次执行
@cli_utils.action_logging
def next_execution(args):
"""
Returns the next execution datetime of a DAG at the command line.
>>> airflow next_execution tutorial
2018-08-31 10:38:00
"""
dag = get_dag(args)
if dag.is_paused:
print("[INFO] Please be reminded this DAG is PAUSED now.")
if dag.latest_execution_date:
next_execution_dttm = dag.following_schedule(dag.latest_execution_date)
if next_execution_dttm is None:
print("[WARN] No following schedule can be found. " +
"This DAG may have schedule interval '@once' or `None`.")
print(next_execution_dttm)
else:
print("[WARN] Only applicable when there is execution record found for the DAG.")
print(None)
airflow dags next-execution <dag_id>