Kincho4
Kincho4

Reputation: 3

How to start python file on startup using linux?

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?

Upvotes: 0

Views: 481

Answers (2)

محمود طاهر
محمود طاهر

Reputation: 3

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

Upvotes: 0

mendacium
mendacium

Reputation: 123

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

Upvotes: 2

Related Questions