I have a python file that I want to start up automatically using raspberry pi. I have searched this up a few times but have found either outdated answers or answers that are very unclear. Does anyone know of a solution?
CodePudding user response:
There are several ways to do so. I couldn't find anything on stackoverflow tho so here you go:
Using the "/etc/rc.local" is probably the quickest/easiest solution:
You have to open rc.local and add whatever you want to execute on startup. In your case something like this:
sudo nano /etc/rc.local
then add the following to the end of the file
sudo python /home/pi/python-program.py &
while "/home/pi/python-program.py" needs to point to your python program
you can find more explanations and other methods here: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/#local