bash_operator.py 860 Bytes
Newer Older
one_jh's avatar
one_jh committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from airflow.operators.bash_operator import BashOperator
from airflow.models import DAG
from datetime import datetime, timedelta

args = {
    'owner': 'airflow',
    'start_date': datetime(2018, 11, 1)
}

dag = DAG(
    dag_id='hello_airflow',
    default_args=args,
    schedule_interval='@once')

# Bash Operator
cmd = 'echo "Hello, Airflow"'
BashOperator(task_id='t1', bash_command=cmd, dag=dag)
# echo """from airflow.operators.bash_operator import BashOperator
# from airflow.models import DAG
# from datetime import datetime, timedelta

# args = {
#     'owner': 'airflow',
#     'start_date': datetime(2018, 11, 1)
# }

# dag = DAG(
#     dag_id='hello_airflow',
#     default_args=args,
#     schedule_interval='@once')

# # Bash Operator
# cmd = 'echo Hello, Airflow'
# BashOperator(task_id='t1', bash_command=cmd, dag=dag)
# """ >> bash_operator.py