1

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)

Thanks!

3
  • 2
    What user is the program running as when started from systemd? Does the program have the proper permissions in any directory it needs to read and write in?
    – NomadMaker
    Jan 4 '20 at 2:38
  • That's a good point. I changed the user to pi (and removed "forking") and it appears to be working. Thank you so much! Jan 4 '20 at 3:32
  • Please make an answer for your solution and accept it after two days. Only accepting an answer will finish the question and it will not pop up again and again for years.
    – Ingo
    Jan 5 '20 at 13:34
1

Changing the User from nobody to pi fixed the issue (as well as removing forking)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.