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

Beginners • Re: Systemd, gpiozero, permissions - boot vs shell

$
0
0
If I start the service from systemctl or a reboot nothing is written even if I run as root.

systemctl status gives

Code:

pi@piRadioZ:~ $ systemctl status piRadio.service× piRadio.service - piRadio     Loaded: loaded (/lib/systemd/system/piRadio.service; enabled; preset: enabled)     Active: failed (Result: exit-code) since Thu 2024-10-03 20:06:07 BST; 32s ago   Duration: 124ms    Process: 789 ExecStartPre=ls -l /dev/gpio* >/tmp/piRadio.log (code=exited, status=2)        CPU: 24msOct 03 20:06:07 piRadioZ systemd[1]: Started piRadio.service - piRadio.Oct 03 20:06:07 piRadioZ ls[789]: ls: cannot access '/dev/gpio*': No such file or directoryOct 03 20:06:07 piRadioZ ls[789]: ls: cannot access '>/tmp/piRadio.log': No such file or directoryOct 03 20:06:07 piRadioZ systemd[1]: piRadio.service: Control process exited, code=exited, status=2/IN>Oct 03 20:06:07 piRadioZ systemd[1]: piRadio.service: Failed with result 'exit-code'.
I'm way out of my depth here, I think I'll just have to run the service as root and stop worrying about why 'pi' doesn't work.
The error here is not what you, nor thagrol, think.
The command line you are using is shell (it uses globbing ("*") and redirection (">")) that systemd will NOT perform for you.
So the ls here is literally looking for a file called "/dev/gpio*" and a file called ">/tmp/piRadio.log". Put all that in a shell script, e.g.

Code:

#!/bin/shls -l /dev/gpio* >/tmp/piRadio.log
and have systemd call that script - using the full path to the script. And make sure the script is executable.

Statistics: Posted by warthog618 — Fri Oct 04, 2024 2:22 am



Viewing all articles
Browse latest Browse all 4151

Trending Articles