I have two services that are normally not related to each other: JBoss and WebSphereMQ.

Now because an application deployed on JBoss requires WebSphereMQ, I would like to configure JBoss to start after WebSphereMQ.

Since the scripts/service files come from package manager I would like to avoid editing them.

Systemd does allow local configuration of Wants and Requires using symlinks to services inside ${service}.wants / ${service}.requires directories however according to documentation Requires does not force ordering, I think the same applies to Wants (documentation is not explicit on that point) but there is no equivalent symlink based functionality for configration of After and Before.

How can I cleanly define this relationship without editing files installed by rpm ?


Your question contains of two separate issues: (a) how to translate services dependency to systemd unit files syntax and (b) how to change unit definitions without changing unit files provided by software vendor.

As for (a), you correctly note that you want After= keyword. JBoss unit file should contain both After=<WebSphereMQ unit name> and Wants=<WebSphereMQ unit name>. Reason for that is: functional dependencies between units and order of units start are separate variables/dimensions. Sometimes you want service A to start every time when service B starts, and that's what Wants= and Requires= are for. Sometimes you want service A to start after service B, if service B is in queue already; that's what After= and Before= are for. Usually you want both of them.

As for (b), you need to use feature called "drop-ins". They are available in systemd since pretty much beginning, but documentation was scattered across many man pages and hard to find. This changed in one of more recent versions (219, I believe), when detailed description was added near end of man systemd.unit.

Drop-ins are small configuration bits that override parts of existing unit definition. Their goal is to allow system administrator to make local changes without having to overwrite unit file provided by software vendor (therefore software updates are a little easier, as you don't have to worry about package manager overwriting your changes).

Drop-ins are text files with names ending with .conf and are placed in <unit name>.d directory.

In your case, you want to create directory /etc/systemd/system/jboss.service.d/ (assuming JBoss comes with jboss.service unit file) and then create file webspheremq.conf with following content:


After reloading systemd configuration (systemctl daemon-reload) you should see changes in systemctl show jboss.service and systemctl status jboss.service. Here is what you can expect from second command (note "Drop-In" line):

● rsnapshot@monthly.service - rsnapshot monthly backup
   Loaded: loaded (/etc/systemd/system/rsnapshot@.service; static)
  Drop-In: /etc/systemd/system/rsnapshot@monthly.service.d
   Active: inactive (dead)

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.