You are not logged in.
I've been trying to figure out the difference between the @ notation and - notation with systemd, and I haven't been able to figure out what the practical difference is.
When creating units, both can be referenced with % specifiers, with %i for @ syntax and %j for - syntax. But what is the difference between creating a unit `prefix@.suffix` and referencing the instantiated units with %i, and creating a unit `prefix-.suffix` and referencing the instantiated units with %j?
Looking through default units, I see there's user@[...].service, but also user-[...].slice. What is the functional difference here that explains why the service uses @ but the slice uses -? Why isn't the slice user@[...].slice, or the service user-[...].service?
from systemd.unit(5):
├───────────┼──────────────────────────────┼──────────────────────────────┤
│ "%i" │ Instance name │ For instantiated units this │
│ │ │ is the string between the │
│ │ │ first "@" character and the │
│ │ │ type suffix. Empty for │
│ │ │ non-instantiated units. │
├───────────┼──────────────────────────────┼──────────────────────────────┤
│ "%I" │ Unescaped instance name │ Same as "%i", but with │
│ │ │ escaping undone. │
├───────────┼──────────────────────────────┼──────────────────────────────┤
│ "%j" │ Final component of the │ This is the string between │
│ │ prefix │ the last "-" and the end of │
│ │ │ the prefix name. If there is │
│ │ │ no "-", this is the same as │
│ │ │ "%p". │
├───────────┼──────────────────────────────┼──────────────────────────────┤
│ "%J" │ Unescaped final component of │ Same as "%j", but with │
│ │ the prefix │ escaping undone. │
├───────────┼──────────────────────────────┼──────────────────────────────┤
Offline
well - although I don't know but from the man I would infer that even
prefix-FINAL@INSTANCE.suffix
is valid - so there's no EITHER / OR but also a combination of both at the same time seems possible - although not / rarely used
also note the specific wording:
while the first one is an INSTANCE - so everything before the @ is the entire prefix - maybe even including an additional FINAL separated by a hyphen - the latter one is included as part of the prefix
also there seems to be a difference between service and slice files
Offline