Why the script fails when run by root?
You have to check the path of the effective user... in this case
(The first two lines are the prompts plus the commands. The last line is the output of the command.)
$ sudo su -
# echo $PATH
Recommendations for where to place your script to be run by others:
Make a subdirectory under
/opt for your project and place your project's exec scripts there. This is a place that will survive an OS fresh install on the same partition (minus formatting of course).
The root area for your scripts can be in:
Now you can link your scripts
$ sudo ln -s /opt/myprojectname/myscriptfile/myscript.sh /usr/local/bin/myscript.sh`
You won't have to change the the
root $PATH variable, because as you can see from the test above, it's already there.
So rather than changing the root path, you can change your path to search the
Alternatively, you could link your