我如何检查何时为特定的dag计划了下一次Airflow DAG运行? [英] How do I check when my next Airflow DAG run has been scheduled for a specific dag?

查看:270
本文介绍了我如何检查何时为特定的dag计划了下一次Airflow DAG运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了气流,并计划将某些DAG安排为每天一次 0 0 * * *。

I have airflow set up and running with some DAGs scheduled for once a day "0 0 * * *".

我想检查下一次是什么时候

I want to check when is the next time a specific dag has been scheduled to run, but I can't see where I can do that within the admin.

推荐答案

如果如果要使用 Airflow CLI ,则有 next_execution 选项

If you want you use the Airflow's CLI, there's next_execution option


获取DAG的下一个执行日期时间。

Get the next execution datetime of a DAG.

airflow next_execution [-h] [-sd SUBDIR] dag_id







UPDATE-1

如果您需要以编程方式进行操作(在气流任务内) ,您可以参考

If you need to do it programmatically (within an Airflow task), you can refer to

  • next_execution(..) function of cli.py
  • (now moved to dag_next_execution(..) function of dag_command.py in master)

@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)


这篇关于我如何检查何时为特定的dag计划了下一次Airflow DAG运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆