How to run a script on startup of Raspberry Pi

In this tutorial, I want to show you, how to simply execute any file on a startup. 

First of all place your file, which should be executed later on an accessible folder. I put my files always on the desktop. So that means my path is something like this:

/home/pi/Desktop/start.py

Now let’s create in the same folder a second file, which we name launch.sh and write there the following two commands:

Now save that file and open the terminal. 

Type there the following command:

sudo crontab -e

It will may ask you, which editor you want. For this case, you could choose the nano editor.

Now the file will open in the terminal. Scroll down and you will see that this file may only contain comments. Just simply add the following line to your file and save it by pressing Ctrl + X and close it.

Logging

As you might noticed, I have entered two paths. The first one is the executable sh file which we have created before and saved on our desktop. The second one is the log file, which the whole output is stored since the startup from your script. Make sure that you have created at least the directory. So in this case you should create the directory logs.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ad blocker detected

We have detected that you are using extensions to block ads. Please support us by disabling your ad blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO