Raspberry Pi_Kor_20.3.5 run level 무관 booting 자동 실행


Published Book on Amazon


All of IOT

Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1

All of IOT

Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사

물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)

최신 라즈베리파이(Raspberry Pi)로 시작하는 사

물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


20.3.5  run level 무관 booting 자동 실행

 

명령이나 script가 특정 run level과 무관하게 항상 실행되도록 하려면 "/etc/rc.local" 파일에 등록하면 된다. 여기에 등록된 script는 통상 시스템이 정상 작동하는 상태인 run level "2" ~"5" 상태에서만 실행된다.  


다음은 "/etc/rc.local" 파일의 내용에 대한 사례이다.

 

#!/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

 

실행문

 

exit 0

 

"실행문"에 해당하는 부분에 원하는 Shell 명령이나 script를 지정하면 booting할 때 자동 실행해준다. 필요한 경우는 여러 개의 실행문을 지정할 수 있다