run_program_at_boot
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
run_program_at_boot [2016/09/07 11:22] – created walkeradmin | run_program_at_boot [2017/01/31 15:52] – walkeradmin | ||
---|---|---|---|
Line 2: | Line 2: | ||
\\ | \\ | ||
\\ | \\ | ||
+ | You can set the Pi to run a program when the unit starts, this is quite often the case if you have a Pi running a task that needs to start if the unit is rebooted (by user or power outage etc). | ||
+ | \\ | ||
+ | \\ | ||
+ | I am running a Python script that displays the current IP Address on a 2 line LCD, I want this to run when the Pi boots (or reboots). The program is called UMD004.py and is located in the / | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | <color blue>We can use the .bashrc file to run a program at boot:</ | ||
+ | \\ | ||
+ | Ensure you are in the /home/pi folder and from the command line run: | ||
+ | |||
+ | sudo nano .bashrc | ||
+ | \\ | ||
+ | \\ | ||
+ | <color blue>At the end of the file add a line to run the Python script:</ | ||
+ | \\ | ||
+ | sudo python / | ||
+ | \\ | ||
+ | \\ | ||
+ | <color purple> | ||
+ | \\ | ||
+ | \\ | ||
+ | The <color Red>&</ | ||
+ | \\ | ||
+ | \\ |
run_program_at_boot.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1