How to start python file on startup using linux?

Question:

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?

Asked By: Kincho4

||

Answers:

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

Answered By: mendacium

Here is a good stuff for running a programm at start up in five way

Answered By: محمود طاهر
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.