How To Run a Script at Boot on Raspberry Pi

RPi Run Script at Boot Post Image

Ever wanted to make a python script run automatically every time you turn your Raspberry Pi on?

If yes, let me present to you the easiest way to do so.

We’ll use cron, a Linux program to schedule tasks.

To use it, just open a terminal and type:

crontab -e

The first time you open it, it’s gonna prompt you witch editor you want to use.

You can pick nano for now.

Once opened, scroll to the bottom and insert the following line:

@reboot python /home/pi/ &

@reboot is the command that tells cron when to execute the script.

Following, is the command we want to run, just like in a terminal.

In this case, we call python and tell it to open the script file.

Lastly, & runs the script in the background.

Read Next

Learn To Code By Playing Games Post Image.png
Raspberry Pi Headless Setup Post Image
Code MicroBit with Makecode