0

I am trying to get this python file with an infinite loop on my raspberry pi to start on boot and stay running while the pi has power. I've tried editing my "etc/rc.local" file and adding the different command variations below. I am certainly referencing the right file and path. I also added a 10 second delay at the beginning of the scrip to make sure everything is in order before it runs. If anyone has any input that'd be great, this is seemingly a common task and I dont know why I am having difficulty.

Additionally I dont have a shebang line at the top of my python script. I dont know if that has anything to do with my problem even though i am specifying the file is a python file.

/usr/bin/python3 /home/pi/Desktop/webplants/mqtt.py & sudo /usr/bin/python3 /home/pi/Desktop/webplants/mqtt.py & sudo python3 /home/pi/Desktop/webplants/mqtt.py & python3 /home/pi/Desktop/webplants/mqtt.py &

1 Answer 1

1

You should use systemd. This utility will easily allow you to run a python script on startup. This tutorial should cover it: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/#systemd

Sign up to request clarification or add additional context in comments.

1 Comment

yea i saw that on the pi's documentation and didnt try it. i will now and get back to you. thanks mane.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.