Just power on your Pi and let a script magically run in the background. This is a beginner tutorial that will put you on the path to making expert projects.
May 30th, 2022
# raspberry pi
There are a bunch of ways to run a script on startup with a Raspberry Pi. I find
crontab the best. It's easy and straightforward which is more than I could ask for when I'm programming.
I'm assuming you have your Pi setup and are able to access a terminal. It doesn't matter if you use ssh or the Pi as a desktop. You also need the script you want to run. In the video and in this tutorial, I use a script called
buzzer.py. It activates a buzzer that I have connected to my Pi's GPIO pins.
In the terminal, run
sudo crontab -e
Now you're editing the
crontab file in the editor Nano. Move your curser to the bottom of the file and add the following code:
@reboot YOUR_SHELL_COMMAND &
YOUR_SHELL_COMMAND" with any command that you can run in your terminal. This is what will be run on startup. Here's what mine looks like:
Ctrl + Sto save and
Ctrl + Xto exit.