How to Run a Script on Startup for Raspberry Pi // EASY

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
by the time you're done with this video you're going to be able to run a script on startup for your raspberry pi without touching any commands maybe you're making a magic mirror maybe you're making a monitor or something like that regardless of what it is this should work for that there are a bunch of ways to do this but i'm only going to be showing one which is crontab i think it's one of the easiest and most straightforward which is more than i could ask for when i'm programming right here i have a script already it's on my desktop called buzzer.pie i have a raspberry pi here and a little buzzer hooked up to it and when i click run it buzzes for a second and that is going to be the example script that i'll be working with for this project but you could use a bash script you could use the python script it doesn't matter this is what you'll change to modify for your application now how do we get it to run on startup let's open up a terminal and then we're going to first run the python script from the terminal just to make sure we have our locations all correct so the command here for me it's going to be python3 home pi desktop buzzer dot pi yep and you heard the buzzing so it worked okay to start up the file from startup we need to do a command sudo cron tab dash e you might have an option that looks like this when you run it for the first time i would select one that's what i did here and it's a nano which is an easy terminal editor okay drop down to the bottom of that file and we're just going to type the command at python 3 home pi desktop buzzer dot pi and amper stamped at the end the reboot signifies when it powers on run this command and then we run the command just like we typed in the terminal that's why it was important we checked it in the terminal because it'll be exactly like how we ran it in the terminal and then the amperstamp at the end means keep running all the jobs don't stop there and only run that command to get out of this we do control s control x and that's it now let's uh power on the pi and see if it worked thanks for watching let me know if you want me to do any other tutorials i also have some fun videos on my channel feel free to check those out and have a great day
Info
Channel: Sam Westby Tech
Views: 57,530
Rating: undefined out of 5
Keywords: autostart raspberry pi script, raspberry pi, run script on boot raspberry pi, raspberry pi bootup script, raspberry pi tutorials, how to automatically run your code on raspberry pi, how to run a script when a raspberry pi boots up, autostart python script at boot, crontab -e, autorun script at boot, raspberry pi setup
Id: Gl9HS7-H0mI
Channel Id: undefined
Length: 2min 56sec (176 seconds)
Published: Fri Jan 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.