Whenever I enable a certain instanced systemd service, I want two timers with the same instance specifier to be enabled as well. This is what my unit file foo@.service looks like:

Description=Does something cool

ExecStart=/usr/bin/foo %i


Running systemctl enable foo@test.service returns:

Failed to enable unit: Invalid argument

If I remove the instance specifiers from the [Install] section and replace them with specific instance names (so it looks like the following), then it works just fine.


The man page systemd.unit(5) says that the %i specifier is interpreted in the install section, so what gives?

The following specifiers are interpreted in the Install section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v.

This seems to be a bug with systemd that reproduces for the Also directive in [Install] section.

However there is a workaround you can use that gives you the same functionality.

Assume you have foo@.service file and you want a corresponding units file. Add the clause in the WantedBy directive instead. Enable the .timer units first with systemctl enable bar1@test.timer etc.

WantedBy=network-online.target bar1@%i.timer bar2@%i.timer

The above works well to start multiple mpd services via socket activation using a service template and several socket files.

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.