I have a program (c program, run using a shell script) that uses sockets to connect to a server, retrieve data (on an interval) and (based on that data) power an LED matrix.
When I run this program manually, it works completely fine, for however long I run it for. However, when I setup systemd to run the program, it crashes about every 1-2 minutes.
Here is the systemd config:
[Unit] Description=Autossh keepalive daemon ## make sure we only start the service after network is up Wants=network-online.target After=network.target [Service] ## use 'Type=forking' if the service backgrounds itself ## other values are Type=simple (default) and Type=oneshot Type=forking ## here we can set custom environment variables ExecStart=/home/pi/nbaboard.sh #ExecStop=/usr/bin/killall -9 autossh ### NOTE: you can have multiple `ExecStop` lines #ExecStop=/usr/bin/killall ssh # don't use 'nobody' if your script needs to access user files # (if User is not set the service will run as root) #User=nobody Restart=always RestartSec=3 # Useful during debugging; remove it once the service is working #StandardOutput=console [Install] WantedBy=multi-user.target
Any idea what I'm doing wrong? Or any pointers on how to better troubleshoot (how/where to add logs, etc.)? (Let me know if I should share code samples for the program. It just uses basic sockets and a c program based on this repo: https://github.com/hzeller/rpi-rgb-led-matrix)