How To Run a Script at Boot on Raspberry Pi
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:
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/your_script.py &
@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.
& runs the script in the background.