본문 바로가기
Raspberry Pi (Linux, ubuntu)

How to Auto Start a Program on Raspberry Pi?

by 소나무기운 2022. 3. 7.
반응형

[2022/04/06] Add title image

[2022/03/07] Start

 

소나무 기운 ,  전자제품 개발/생산

How to Auto Start a Program on Raspberry Pi? (rc.local)

라즈베리파이 부팅시 프로그램 자동실행.

 

 

Edit rc.local file.

sudo nano /etc/rc.local

edit rc.local file using nano-editor.

 

 

 

소제목 2

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

sleep 10
cd /home/pi
./EXE_filename &

exit 0

slepp 10 : It can be delayed for 10 seconds.

cd /home/pi : goto /home/pi

./EXE_filename : Execute the EXE_fileneme.

& : EXE_filename allows continuous execution by itself.

     프로그램이 끝날때까지 기다리지 않고 실행될수 있도록 해 놓고 빠져나온다.

 

 

How to use nano-editor

nano editor

Ctrl + O : (Write Out) Save file.

Ctrl + X : Exit

 

save menu

If you type enter, it's saved.

 

 

마무리

/etc/rc.local

If you enter it as above, you can run it without rebooting.

위에서 처럼 입력하면 재부팅하지 않고 실행해볼수 있다.

 

참고문헌

 

 

 

 

 

틀린 부분이나 질문은 댓글 달아주세요.

즐거운 하루 보내세요. 감사합니다.

 

 

반응형

댓글