Running a script at startup with rc.local (permission denied)
# ls test.sh
-rw-r--r-- 1 root root 0 nov 27 13:40 test.sh
# ./test.sh
-su: ./test.sh: permission denied
To solve:
# chmod +x test.sh
Change test.sh
for /path/to/myscript.sh
Related videos on Youtube
stefan83
Updated on September 18, 2022Comments
-
stefan83 over 1 year
I prepared an image and included in
/etc/rc.local
a line to run a script:/path/to/myscript.sh
I then created a script at that location
It contains a curl, to download and save a file as new file to the system. After this the file should be executed.
My problem is the following:
The content of the script I included directly to
rc.local
before and got an errorpermission denied
.
It was the line downloading a scriptfile and save it locally.Now I started to read further post and all said, it's better to exclude commands to a script file and launch the script file via rc.local only.
But the permissions-problem persists.
So I tried to modify my
rc.local
line:/path/to/myscript.sh # not working sudo /path/to/myscript.sh # not working
also in my script I added
sudo
to each command, it's not working.Currently it seems curl with saving a file isn't allowed. (Internet connection exists).
Other posts say I should install a service. Now I think it's going oversized and have no warranty. I need to run the script only once at reboot. In the script I tell the device to download bash-scripts and execute them.
So it seems I have a permission problem and I don't know how to fix it.
Maybe I used the wrong method to run a script after boot.
Why does this problem occur and how to fix ?
-
AlexP over 7 yearsAre you sure that the script
/path/to/myscript.sh
is actually executable? What doesls -l /path/to/myscript.sh
say?
-
-
WinEunuuchs2Unix over 5 yearsHmm you were a three year member with 1 point. Well now you have 11 points :)
-
Alonso Lara over 5 yearsThanks! Will I get the 15 points in the next decade? ;)