RaspBerry PI

AutoRun(=RPi 부팅할때 Run시키기)

ElectricShock 2018. 3. 27. 23:14

https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/


Run a Program On Your Raspberry Pi At Startup


In this tutorial,

we show you Five Ways you can run a program

on your Raspberry Pi

at startup.

The Five methods that are available to run a program at boot are:

●rc.local

●.bashrc

●init.d tab

●systemds

●crontab


Sample Program

You can use any program that you want to run at boot
;For this tutorial, we are using a sample python program which will speak at the startup of Raspberry Pi.
This sample program will use the Espeak package installed, 
run the following in terminal to install:

sudo apt-get install espeak

To learn more about how to get the Raspberry Pi speak,
we have a tutorial here.

In the /home/pi directory,

open a file for editing:


sudo nano sample.py


And enter the following code and save it (Press CTRL+X and Enter Y).

#! /user/bin/env python

from subprocess import call

call (['espeak "Welcome to the world of Robots" 2>/dev/null'], shell=True)




Method1 : rc.local

The first method to run a program on your Raspberry Pi at startup

is to use the file rc.local.

In order to have command or program run when the Pi boots,

you can add commands to the rc.local file.

This is especially useful

if you want to power up your Pi in headless mode

(that is without a connected monitor),

and have it run a program without configuration or a manual start.

Editing rc.local

On your Pi, edit the file /etc/rc.local using the editor of your choice.

You must edit it with root permissions:

sudo nano /etc/rc.local


Add commands to execute the python program, preferably using absolute referencing of the file location




RPi AudoRun (드라마 스위치에서 (장근석 주연))