Is there a way to pause a task for 24 hours then run the same task again?
I want to write a dag that pull data from api, but the api have limit of data I can pull in a day so I need to wait for 24 hours to pull the data again.
so I want the dag to work like
task1–> dag pause for 24 hours –> task1
New contributor
Nutzuchima is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
You can use Cron Presets such as @daily for this use case.
Your sample DAG would like the following:
<code>from airflow.decorators import dag, task
@dag(schedule=@daily, start_date=datetime(2024, 1, 1), catchup=False)
def sample_dag():
@task
def sample_task():
print(f"Sample DAG")
task()
sample_dag()
</code>
<code>from airflow.decorators import dag, task
@dag(schedule=@daily, start_date=datetime(2024, 1, 1), catchup=False)
def sample_dag():
@task
def sample_task():
print(f"Sample DAG")
task()
sample_dag()
</code>
from airflow.decorators import dag, task
@dag(schedule=@daily, start_date=datetime(2024, 1, 1), catchup=False)
def sample_dag():
@task
def sample_task():
print(f"Sample DAG")
task()
sample_dag()