Skip to main content

Force a service to start before networking.service [Resolved]

I would like to start my service samplerbox.service

Description=Starts SamplerBox

ExecStart=/root/SamplerBox/          # this script does: python /root/SamplerBox/


before networking.service (DHCP thing, IP attribution, etc.) has finished.

Remark: my program doesn't use networking at all.

Here is the plot (bigger size here):

As you can see, samplerbox.service exactly waits for networking.service to be finished. (I did several tests, and it is the same).

I tried: replace by something else like and then systemctl disable samplerbox.service and reenable it... But this was unsuccessful!

How to force a service to start before networking.service?

Question Credit: Basj
Question Reference
Asked July 18, 2019
Posted Under: Unix Linux
1 Answers

samplerbox.service is started after networking has finished.

True, but only an incidental and not what is actually happening. If you look carefully at the graph you'll find that samplerbox.service is being started after This is normal and by design in systemd. Most (non-system) services have "default dependencies" set, which are implicit dependencies and orderings that are not written out in the service unit. A dependency from and an ordering after it is one such default that is applied by systemd, unless the defaults are explicitly disabled in the service unit.

You are also conflating ordering and dependency. The various "wants" directives, such as WantedBy that you have been playing with and its reverse Wants, specify dependencies. They make systemd queue a job to also start service B if a request is made to start service A. They do not specify the orderings of those jobs. Orderings are controlled by other settings, namely the fairly obviously named Before and After.

Dependencies specify what overall set of start and stop jobs is constructed from a simple command such as systemctl start Orderings specify when and in what order those jobs are then executed.

Further reading

  • Lennart Poettering (2013-10-07). systemd.unit. systemd manual pages.
  • Lennart Poettering (2013-10-07). systemd.service. systemd manual pages.

credit: JdeBP
Answered July 18, 2019
Your Answer