I'm having an insane amount of trouble with my script at startup, I've tried countless ways and spent hours trying to get this to work.
I have a python script that I need to run at startup. However, it needs access to the internet, so I have to wait for the network.
I have tried many ways in the several tutorials I have tried, with crontab, by making a service with systemd, with rc.local however none of these have worked.
The only way that I was able to work was by doing a .desktop Desktop Entry, but that only worked for me while I had an external monitor plugged in, and my raspberry pi will be running without one.
Also, I was able to make my script run using the service method and now the rc.local
by adding this line:
sudo bash -c '/usr/bin/python3 /home/pi/Projects/capstone/main.py > /home/pi/capstone.log 2>&1' &
However, in the python script that I am trying to run, I have the following code:
os.system("sudo killall servod") time.sleep(1) os.system('sudo ~/PiBits/ServoBlaster/user/./servod')
And for some reason, it's not running my script correctly because I get the following error in my logs:
servod: no process found sudo: /root/PiBits/ServoBlaster/user/./servod: command not found
The first one is expected because I run sudo killall servod when it may or may not be started, but the second one "Command not found" is what is the issue, if that bit of code doesn't get executed my program doesn't work.
Anyone out there could help me out with this?