아래 링크에 잘소개 되어 있다.

https://www.digikey.kr/en/maker/projects/how-to-run-a-raspberry-pi-program-on-startup/cc16cb41a3d447b8aaacf1da14368b13

 

How to Run a Raspberry Pi Program on Startup

How to Run a Raspberry Pi Program on Startup Courtesy of Sparkfun Introduction The Raspberry Pi is a great single board computer, but like most computers, its functions rely mostly on human input. That means whenever you start up (or boot) your computer, i

www.digikey.kr

 

라즈베리 파이는 rc.local에 exit0 이전에 실행하고자 하는 명령어를 쓰면 잘된다.

그런데 python 스크립트나 node의 경우는 라이브러리 경로를 잘 명시해야 한다.

node의 경우 npm이 프로젝트 경로에 모아서 주니까 문제가 없는데 파이썬의 경우

기본적으로  rc.local이 root로 실행하기 때문에 아무런 PATH 설정이 없어서 library를 못찾는다.

따라서 pi 계정으로 실행하도록 해야 한다.

 

$ sudo vi /etc/rc.local

~~~

sudo -H -u pi python <my script path>

exit 0

 

이런식으로 실행해야 라이브러리를 찾는데 문제가 없을 것이다.

만약에 rc.local이 활성화 되지 않았다면 systemd를 이용해서 이를 활성화 해야한다.

http://blog.naver.com/PostView.nhn?blogId=kick8888&logNo=220922201750&beginTime=0&jumpingVid=&from=search&redirect=Log&widgetTypeCall=true

 

우분투 16.10 (systemd) 기반의 rc.local 활성화

우분투 최신버전은 systemd 기반으로 PID들이 관리된다, 필자는 rc.local을 부득이 하게 사용할 일이 생...

blog.naver.com

 

+ Recent posts