"Permission denied" when running dag to create new directory

Hello Team

I’m create simpe DAG to create new directory with bash operator. i have running in docker.
but an error “Permission denied”

from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.dummy import DummyOperator
from datetime import datetime, timedelta

dag = DAG(
dag_id=“test_create_directory”,
tags=[“test_create_directory”],
schedule_interval=“@daily”,
start_date=datetime(2023, 1, 1),
end_date=datetime(2023, 1, 5),
)

task_mkdir = BashOperator(
task_id=“create_directory”,
bash_command=“/usr/local/airflow/dags/bash_operator/scripts/create_dir.sh”,
dag=dag
)

start_task = DummyOperator(task_id=“start_task”, dag=dag)
end_task = DummyOperator(task_id=“end_task”, dag=dag)

start_task >> task_mkdir >> end_task

and this is bash script

#!/bin/bash

cd /usr/local/airflow/

mkdir test_create_dir

please help me.

Hello @syarif1

As per the error “Permission denied”, it seems like the execute permissions are missing from the script. Could you please add the execute permission to your script and try again?

Thanks
Manmeet

Hello Manmeet

How do I add permissions for file access?
is it using chown -R astro:astro <fille_name>?

but unfortunately the astro user does not exist.

Thanks
Syarif

Hey @syarif1

On your local machine, you can simply give execute permission to the script. Like this:

chmod +x dags/bash_operator/scripts/create_dir.sh

There is no need to change the owner of the script, just giving execute permissions should resolve the error. Let me know if you still face the issue.

Thanks
Manmeet