Skip to content

Commit d80b187

Browse files
coder2jcoder2j
coder2j
authored and
coder2j
committed
MINOR: Add Tutorial of scheduling airflow dag with cron expression
1 parent 143585d commit d80b187

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

dags/dag_with_cron_expression.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from datetime import datetime, timedelta
2+
3+
from airflow import DAG
4+
from airflow.operators.bash import BashOperator
5+
6+
7+
default_args = {
8+
'owner': 'coder2j',
9+
'retries': 5,
10+
'retry_delay': timedelta(minutes=5)
11+
}
12+
13+
with DAG(
14+
default_args=default_args,
15+
dag_id="dag_with_cron_expression_v04",
16+
start_date=datetime(2021, 11, 1),
17+
schedule_interval='0 3 * * Tue-Fri'
18+
) as dag:
19+
task1 = BashOperator(
20+
task_id='task1',
21+
bash_command="echo dag with cron expression!"
22+
)
23+
task1

0 commit comments

Comments
 (0)