0

Running up to date Arch Linux ARMv7 (RaspPi 3). I have two systemd service units which I have created. I want foo to start first and then bar. foo starts on boot and bar does not. However bar will start manually from a shell prompt. Here is a copy of the bar unit file:

[Unit]
Requires=foo.service
After=foo.service

[Service]
Type=simple
ExecStart=/usr/bin/setsid /usr/bin/bar >/dev/null 2>&1 < /dev/null
TimeoutSec=0
RemainAfterExit=Yes

[Install]
WantedBy=getty.target

However if I put a pound symbol in front of [Unit] like so:

#[Unit]

Then bar starts at boot in the right order (after foo).

This behaviour and commenting out of the [Unit] line doesn't seem to make sense or fit in with the documentation I can find. So I'm just wondering why it makes the unit start at boot?!

  • Someone has downvoted the question... please comment to tell me what I did wrong? I have spend a lot of time going through documentation to find an answer and can't. – bao7uo Dec 14 '16 at 9:34
  • 1
    Are the four lines above all of the service file? – MariusMatutiae Dec 14 '16 at 10:59
  • @MariusMatutiae No, sorry - added the whole file now – bao7uo Dec 14 '16 at 11:18
  • It's circular: you are trying to start /usr/bin/bar but the service file says it requires bar, and must be started after bar. – MariusMatutiae Dec 14 '16 at 11:23
  • sorry @MariusMatutiae my mistake! edited again... it's because foo and bar are not the real service names. I renamed them for the question and confused myself!! – bao7uo Dec 14 '16 at 11:24
1

Commenting out [Unit] causes the Requires and After directives to be ignored. Removing those directives and removing the comment # gives identical behaviour.

The reason it was not starting at boot without the comment # must be because of an issue with the requirement for the other service.

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.