I want to start a script every time my RPi starts and have it run as a background process that automatically restarts if it has an issue. The script is called mediamtx_start.sh and is located in the user pi folder. Here is how I have configured systemd using .
I ran these commands But, when I check on the status, I get this result:When I just run this command......the stream starts every time.
Code:
sudo nano /lib/systemd/system/lasercam.service
Code:
[Unit]Description=Laser Camera Start ScriptAfter=network.target[Service]ExecStart=/home/pi/mediamtx_start.shRestart=alwaysRestartSec=10User=pi[Install]WantedBy=multi-user.target
Code:
sudo systemctl daemon-reload
Code:
sudo systemctl enable lasercam.service
Code:
sudo systemctl start lasercam.service
Code:
pi@lasercam:~ $ sudo systemctl status lasercam.service● lasercam.service - Laser Camera Start Script Loaded: loaded (/etc/systemd/system/lasercam.service; enabled; preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Mon 2024-12-09 18:55:12 EST; 103ms ago Process: 22324 ExecStart=/home/pi/mediamtx_start.sh (code=exited, status=127) Main PID: 22324 (code=exited, status=127) CPU: 16ms
Code:
/home/pi/mediamtx_start.sh
Statistics: Posted by afgoody — Mon Dec 09, 2024 11:59 pm