Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4919

Advanced users • systemd Status 127

$
0
0
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

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
I ran these commands

Code:

sudo systemctl daemon-reload

Code:

sudo systemctl enable lasercam.service

Code:

sudo systemctl start lasercam.service
But, when I check on the status, I get this result:

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
When I just run this command...

Code:

/home/pi/mediamtx_start.sh
...the stream starts every time.

Statistics: Posted by afgoody — Mon Dec 09, 2024 11:59 pm



Viewing all articles
Browse latest Browse all 4919

Trending Articles