I have a Debian stretch on RPI. I need to start a custom service on boot up.


Service is enabled, but shows up as inactive

lora-packet-forwarder.service - LoRa Packet Forwarder
   Loaded: loaded (/lib/systemd/system/lora-packet-forwarder.service; enabled; vendor preset: enabled)
   Active: inactive (dead)


sudo journalctl -f -u lora-packet-forwarder.service 

-- shows up nothing

If I start it manually from console, it works fine:

sudo systemctl start lora-packet-forwarder.service

lora-packet-forwarder.service - LoRa Packet Forwarder
   Loaded: loaded (/lib/systemd/system/lora-packet-forwarder.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-07-05 15:01:48 BST; 3s ago
  Process: 554 ExecStartPre=/home/pi/lora_gateway/reset_lgw.sh start (code=exited, status=0/SUCCESS)
 Main PID: 570 (lora_pkt_fwd)
   Memory: 568.0K
   CGroup: /system.slice/lora-packet-forwarder.service
           └─570 /home/pi/packet_forwarder/lora_pkt_fwd/lora_pkt_fwd

Jul 05 15:01:47 raspberrypi systemd[1]: Starting LoRa Packet Forwarder...
Jul 05 15:01:47 raspberrypi reset_lgw.sh[554]: Accessing concentrator reset pin through GPIO25...
Jul 05 15:01:48 raspberrypi systemd[1]: Started LoRa Packet Forwarder.

Here are the contents of the service file:

Description=LoRa Packet Forwarder

ExecStartPre=/home/pi/packet_forwarder/lora_pkt_fwd/reset_lgw.sh start


I have a small shell script to reset the GPIO pin, before the lora_pkt_fwd is launched. Here are the permissions for both files:

-rwxr-xr-x 1 pi pi  1485 Jul  3 21:38 reset_lgw.sh
-rwxr-xr-x 1 pi pi 144680 Jul  3 20:17 lora_pkt_fwd

Regarding the settings, have tried already:

  1. put "bash" for shell script - ExecStartPre=bash /home/pi/packet_forwarder/lora_pkt_fwd/reset_lgw.sh start
  2. Tried combinations of After=network.target, Before=network-online.target, Wants=network-online.target in [Unit] section
  3. Tried Type=simple and forking in [Service] section
  4. Tries disable/enable the service and daemon-reload (just in case)

I could get this done with cron task or something , but I want to do it right.

  • Did you run systemctl enable lora-packet-forwarder.service? – derobert Jul 5 at 15:01
  • I'm 99% guessing that the service has a dependency that hasn't yet been fulfilled during boot but is fulfilled after boot. – barrycarter Jul 5 at 19:39
  • derobert, yes I did already – Sergi Jul 6 at 1:23
  • @barrycarter, exactly, that's why (I assume) I tried these params "After=network.target, Before=network-online.target, Wants=network-online.target " hoping that service might be failing due to absence of the network connection. I wonder if there is a debug switch so I can get a more verbose reason/log? – Sergi Jul 6 at 1:28
  • Please include the output of systemctl status lora-packet-forwarder.service right after bootup, once systemctl list-jobs is already empty. – Ferenc Wágner Aug 31 at 16:10

Your Answer

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

Browse other questions tagged or ask your own question.