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

 

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

野狼e族

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值