I have a service that depends on another:



The kool things:

  • Running systemctl stop main causes this dependent service to also stop
  • Running systemctl restart main causes dependent service to also get started

But, running systemctl main start does not cause this dependent service to get started.

How do I do it?

1 Answer 1


The After= and Before= parameters are strictly for ordering the startup (and maybe the shutdown) of two services if both are asked to be started. Having a service listed there doesn't mean that those services will also be started up.

If you want to control whether or not another service gets started, you need to use Requires=, Wants=, or Conflicts= (which go in the [Unit] section) or WantedBy= (which goes into the [Install] section).

In your case, you want to start a service when something it's dependent on is started (which doesn't happen automatically, as there is no reason to do so). You'll want to add the following to the file and then run systemctl enable dependent:


This says that when main is started, to also start this service, and that if this service happens to fail, then don't stop main.

  • 1
    It's worth noting that by itself, adding the WantedBy= as suggested won't get the other service to start with systemctl start main.service. It's not until the main.service is enabled that happens. See the associated docs for WantedBy= here... Commented Nov 20, 2017 at 19:44
  • Sorry, forgot the link: man7.org/linux/man-pages/man5/systemd.unit.5.html Also note that still doesn't seem to work for my test despite creating a symlink. Using "Wants=" instead in the Unit section works the best but requires a potentially unwanted reference from main.service back to the dependent service. Commented Nov 20, 2017 at 19:54
  • Thank you for this ! It works fine.
    – ZedTuX
    Commented May 8, 2020 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .