0

I have added my service to systemd (I am running it on a pi3), it looks like this:

[Unit]
Description=Oral-B BLE scanner service
Wants=network-online.target
After=network-online.target
StartLimitBurst=10
StartLimitIntervalSec=10
Requires=bluetooth.target

[Service]
Type=simple
WorkingDirectory=/home/pi/scripts
ExecStart=/home/pi/scripts/scanOralB.py
Restart=always
RestartSec=10

[Install]
WantedBy=network-online.target

I have added a symbolic link to the above file in /lib/systemd/system. I have enabled the service as well. Just to be sure I checked.

pi@raspberrypi:~ $ systemctl is-enabled scanOralB.service
enabled

If I reboot and check the status it looks like this:

pi@raspberrypi:~ $ sudo systemctl status scanOralB.service
* scanOralB.service - Oral-B BLE scanner service
   Loaded: loaded (/home/pi/scripts/scanOralB.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

If I start the service manually it works just fine. Can someone explain why the service is not being started after boot? I get no extra output from journalctl either.

1
  • Have you tried systemctl enable scanOralB.service instead of add symbolic link? – Yurij Goncharuk Apr 10 '20 at 21:29
2

It's not being started because it's not wanted by anything that gets started.

[Install]
WantedBy=network-online.target
I have added a symbolic link to the above file in /lib/systemd/system.

Pretty much all of that is wrong.

  • The unit file should be placed in /etc/systemd/system. Symbolic links are interpreted idiosyncratically by systemd, and do not have the conventional filesystem semantics. And /lib/systemd/system is not the place for hand-written unit files that do not come from packages.
  • The unit file should be wanted by something that actually gets started at bootstrap. network-online.target usually does not. multi-user.target is the usual choice. graphical.target is another.
2
  • thanks for the explanation, I actually managed to solve this myself, changing to graphical.target but the location really did not matter, at least not for me. also the fact of it being a symlink or actual file did not seem to matter either. – theAlse Apr 11 '20 at 10:22
  • Where are you supposed to put service files that don't originate in a package? – Luke Hutchison Aug 6 '20 at 5:43

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.