You are not logged in.

#1 2016-08-15 19:22:13

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

Enabling multiple systemd unit files with the same instance specifier

Whenever I enable an 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:

[Unit]
Description=Does something cool
Documentation=man:foo(1)

[Service]
Type=forking
ExecStart=/usr/bin/foo %i
PIDFile=%t/foo/foo.pid
StandardOutput=journal

[Install]
WantedBy=network-online.target
Also=bar1@%i.timer
Also=bar2@%i.timer

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.

Also=bar1@test.timer
Also=bar2@test.timer

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.

Last edited by thePhysicist8 (2016-08-16 01:31:05)

Offline

#2 2016-08-15 20:42:21

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: Enabling multiple systemd unit files with the same instance specifier

This seems to be a bug with the “Also” directive, as “WantedBy” happily takes %i

Offline

#3 2016-08-16 21:09:01

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

Re: Enabling multiple systemd unit files with the same instance specifier

Do you think that this could be a bug with systemd (even one specific to my setup), or is this the intended behavior?

Offline

#4 2016-08-17 00:01:47

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: Enabling multiple systemd unit files with the same instance specifier

Before I posted, I tried this on my system and I got the same as you. I also tried “WantedBy” which did work. You'd expect “Also” to work from reading the systemd.unit man page.

If something is not working as documented, that's a bug.

Offline

Board footer

Powered by FluxBB