-1

I have a setup where I have a servercabinet with an external display that shows various system information. I only want it to turn on when I am present though, and I have made it soundactivated using SoundMeter https://github.com/shichao-an/soundmeter and a cheap USB microphone. When run manually everything works as it sohuld, but when i try to run it as a systemd service or a cronjob, it wont execute the second script that starts the display. From the logs I can see that Soundmeter works as it should, but it doesn't fire up the display.

Systemd service:

[Unit]
Description=Soundmeter

[Service]
Type=simple
Restart=always
#RestartSec=120
User=pi
ExecStart=/usr/local/bin/soundmeter -t +25 -a exec -e /opt/sysdroidUHHD/trigger.sh

[Install]
WantedBy=multi-user.target

Cronjob

@reboot /usr/local/bin/soundmeter -t +25 -a exec -e /opt/sysdroidUHHD/trigger.sh &

Contents of trigger.sh

#!/bin/bash

python3 /opt/sysdroidUHHD/sysdroid_main.py
exit 0

Any and all help is appreciated.

tristan202
  • 1,081
  • 3
  • 19
  • 28
  • Does this answer your question? [Cron job: how to run a script that requires to open display?](https://stackoverflow.com/questions/11015029/cron-job-how-to-run-a-script-that-requires-to-open-display) – pjh Sep 05 '22 at 18:43
  • No, it doesn't require any display. The display i use is a LED matrix that connects via GPIO. – tristan202 Sep 05 '22 at 18:57
  • From the tag: systemd questions should be for *programming questions* using systemd or its libraries. Questions about *configuring the daemon* (including writing unit files) are better directed to Unix & Linux: https://unix.stackexchange.com. – Rob Sep 06 '22 at 08:45

1 Answers1

0

Remove that exit 0 from trigger.sh. Make sure your sysdroid_main.py starts some server or daemon that won't exit.

Niraj Nandane
  • 1,318
  • 1
  • 13
  • 24