i can run this everywhere on my shell:
bash ~/Documents/myfolder/subfolder/service/autorun.sh
this is my autorun.sh this should start the builded go webservice:
#!/bin/bash cd ./bin/ sudo ./client-service
this works if i run it on my shell. But if i want to use it in my rc.local for autostart on raspbian with this code:
bash ~/Documents/myfolder/subfolder/service/autorun.sh
The bash script should start the go webserver.
~/Documents/myfolder/subfolder/service/bin/client-service
But it won't start
I hope someone can help me with this problem! thx
You are using the '~' character in your path. That means that the path is relativ to the home-directory of the user that is running the script. Calling the script as a user, everything works fine, but calling the script as root user, it will try to use /root/Documents/myfolder/sub... as path and this will not work. Try to do run the script with an absolute path, or even better try to deploy your service on a more common place.
It seems that i had to install a service within /etc/init.d -> now i works without any problems (with the same script & absolute path)