我有一个Bash脚本,它会创建一个文件(如果该文件不存在),我希望在Airflow中运行该脚本,但尝试后失败了。我该怎么做?
#!/bin/bash
#create_file.sh
file=filename.txt
if [ ! -e "$file" ] ; then
touch "$file"
fi
if [ ! -w "$file" ] ; then
echo cannot write to $file
exit 1
fi
这是我在Airflow中调用它的方式:
create_command = """
./scripts/create_file.sh
"""
t1 = BashOperator(
task_id= 'create_file',
bash_command=create_command,
dag=dag
)
lib/python2.7/site-packages/airflow/operators/bash_operator.py", line 83, in execute
raise AirflowException("Bash command failed")
airflow.exceptions.AirflowException: Bash command failed
template_ext = ('.sh', '.bash',)
这些扩展名在 Operator 类中被定义为模板扩展名。因此,它们被视为模板而不是文件执行。 - Nabin