I am somewhat new to raspberry PI and this is my first attempt to add a systemd service.
I am trying to run a python script at startup.
The python script and .venv are in the following directory:Below is the status of the sensor_sample.service:
Thank you for any help on this!
I am trying to run a python script at startup.
The python script and .venv are in the following directory:
Next is the code I entered into /lib/systemd/system/sensor_sample.service:/home/randy/Documents/GitHub/smrtpype-sensor-sampler
Code:
[Unit]Description=SamplerAfter=multi-user.target[Service]Type=SimpleWorkingDirectory=/home/randy/Documents/GitHub/smrtpype-sensor-samplerExecStart=/home/randy/Documents/GitHub/smrtpype-sensor-sampler/.venv/bin/activate /home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.pyReStart=on.abort[Install]WantedBy=multi-user.target
x sensor_sample.service - Sampler
Loaded: loaded (/lib/systemd/system/sensor_sample.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Wed 2024-12-11 08:20:13 EST; 4min 6s ago
Duration: 3ms
Process: 3509 ExecStart=/home/randy/Documents/GitHub/smrtpype-sensor-sampler/.venv/bin/activate /home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.py (code=exited, status=203/EXEC)
Main PID: 3509 (code=exited, status=203/EXEC)
CPU: 2ms
Dec 11 08:20:13 raspberrypi (activate)[3509]: sensor_sample.service: Failed at step EXEC spawning /home/randy/Documents/GitHub/smrtpype-sensor-sampler/.venv/bin/activate: Permission denied
Dec 11 08:20:13 raspberrypi systemd[1]: Started sensor_sample.service - Sampler.
Dec 11 08:20:13 raspberrypi systemd[1]: sensor_sample.service: Main process exited, code=exited, status=203/EXEC
Dec 11 08:20:13 raspberrypi systemd[1]: sensor_sample.service: Failed with result 'exit-code'.
Thank you for any help on this!
Statistics: Posted by rlabidin — Wed Dec 11, 2024 1:29 pm