User Tools

Site Tools


run_program_at_boot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
run_program_at_boot [2016/09/07 11:22] – created walkeradminrun_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 /home/pi/Python directory. 
 +\\  
 +\\  
 +\\  
 +<color blue>We can use the .bashrc file to run a program at boot:</color> 
 +\\  
 +    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:</color> 
 +\\  
 +    sudo python /home/pi/Python/UMD004.py & 
 +\\  
 +\\  
 +<color purple>Note:</color> 
 +\\  
 +\\  
 +The <color Red>&</color> is important if your program does not end (say its a looping program) the <color Red>&</color> tells raspbian not to wait for the program to terminate before continuing. 
 +\\  
 +\\ 
run_program_at_boot.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1