embeded/raspberry pi2024. 8. 27. 16:13

결국은 systemd에 등록인데..

python 프로그램의 경우 pip -g로 인스톨 해서 전역으로 하지 않으면

대부분(?) 에러가 나던데.. 그건 언급이 없네

 

cd /lib/systemd/system/
sudo nano hello.service
The service definition must be on the /lib/systemd/system folder. Our service is going to be called "hello.service":

[Unit]
Description=Hello World
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/python /home/pi/hello_world.py
Restart=on-abort

[Install]
WantedBy=multi-user.target

Here we are creating a very simple service that runs our hello_world script and if by any means is aborted is going to be restarted automatically. You can check more on service's options in the next wiki: https://wiki.archlinux.org/index.php/systemd.

Now that we have our service we need to activate it:

sudo chmod 644 /lib/systemd/system/hello.service
chmod +x /home/pi/hello_world.py
sudo systemctl daemon-reload
sudo systemctl enable hello.service
sudo systemctl start hello.service

[링크 : https://gist.github.com/emxsys/a507f3cad928e66f6410e7ac28e2990f]

'embeded > raspberry pi' 카테고리의 다른 글

pgadmin4 를 rpi에 설치하기 성공  (0) 2024.07.29
pgadmin3 안되잖아?!  (0) 2024.07.26
rpi pico ADC 범위  (0) 2024.07.16
rpi pico / micropython  (0) 2024.07.15
rpi 콘솔 옮기기  (0) 2024.02.26
Posted by 구차니