Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Airflow - how to get all the future run date

I am working on scheduling a airflow job. However to verify if I have scheduled the correct job I need to see when it will run in the future.

Airflow has following command which gives me the next run. however, that's not sufficient for some use cases. for example, I have scheduled a job run every other Friday. How do I verify that.

airflow next_execution <dag_id>

Is there a way, I can get all the future dates when this dag will run. or atleast couple of ?

like image 463
Gaurang Shah Avatar asked Oct 27 '25 17:10

Gaurang Shah


1 Answers

While most processes use croniter, if you have access to your installation it's always best to get the information from the "source" via existing interfaces:

from airflow import models
from datetime import datetime, timedelta


dag_bag = models.DagBag()

dag_id = "dag_name"
dag = dag_bag.get_dag(dag_id)

now = datetime.now()
until = now + timedelta(days=21)

runs = dag.get_run_dates(start_date=now, end_date=until)
print(runs)
like image 131
joebeeson Avatar answered Oct 30 '25 14:10

joebeeson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!