airflow - 在 Airflow 中执行 Talend Job .sh 文件 - Bash 命令失败时出错
问题描述
我正在使用适用于 Linux 的 Windows 子系统
使用命令从 D 盘复制 talend 作业文件夹:cp -R /mnt/d/path /home/path
使用命令更改.sh
文件权限:chmod 777 abc.sh
bash 命令:"/home/path/abc.sh "
还尝试了 bash 命令:'{{"/home/path/abc.sh"}}'
手动执行任务为:airflow test abc123 abc123 2020-07-12
如果我错过了一些步骤,需要帮助
解决方案
# this import is used to instantiate dag
from airflow import DAG
# this import is used to run the tasks
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
#Passing the sh file
execute_command = "/path/execute_sql_script_file_run.sh "
# this is the arguments used by the bash operator
default_args = {
'owner': 'abc',
'depends_on_past': False,
'start_date': datetime(2020, 7, 12),
'retries': 1,
'retry_delay': timedelta(minutes=5),
'catchup': False
}
# instantiate a DAG
dag = DAG(
'abc123', default_args=default_args,schedule_interval="@once")
#task are given some specific arguments we can also override the default_args here.
t1 = BashOperator(
task_id='abc123',
bash_command=execute_command,
dag=dag)
实际上它需要复制使用 Build 导出的整个 TalendJob 文件夹(包含所有 jar 文件/库)。
这对我有用。
谢谢