BashOperator實例

特別注意:bash_command 命令後需要添加一個 空格,否則會報錯

# -*- coding: utf-8 -*-
from datetime import timedelta
import airflow
from airflow import DAG
from airflow.operators.bash_operator import BashOperator

default_args = {
    'owner': 'hdfs',
    'depends_on_past': False,
    'start_date': airflow.utils.dates.days_ago(0),
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}
# new add mac dag daily
dag = DAG(
    'newmac_dag',
    default_args=default_args,
    description='Some DAG',
    schedule_interval="@once",
)
# download kuyun new mac
t1 = BashOperator(
    task_id='download_kuyun_new_mac',
    bash_command='/kuyun-wiwide/script/start-download-kuyun-new-mac-d.sh {{ dag_run.conf.date }}  {{ dag_run.conf.url }}',
    dag=dag,
)
# start new mac job daily
t2 = BashOperator(
        task_id='kuyun_new_mac_job',
        bash_command='/kuyun-wiwide/script/script.sh {{ dag_run.conf.date }}  ',
        dag=dag,
)
# start generate new match mac track data job
t3 = BashOperator(
        task_id='generate_new_match_mac_track',
        bash_command='/kuyun-wiwide/script/script.sh {{ dag_run.conf.date }} ',
        dag=dag,
)
# start search new mac matched track job daily
t4 = BashOperator(
        task_id='search_new_match_mac_track',
        bash_command='/kuyun-wiwide/script/script.sh {{ dag_run.conf.date }} ',
        dag=dag,
)
# call kuyun's API
t5 = BashOperator(
        task_id='start_download_kuyun_new_mac',
        bash_command='/kuyun-wiwide/script/start-download-kuyun-new-mac-d.sh {{ dag_run.conf.date }} ',
        dag=dag,
)
t1 >> t2 >> t3 >> t4 >> t5

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章