I'm working with an external service that creates its own systemd scopes like system.slice/someapp.slice/instance-400.scope
or user.slice/user-1000.slice/app-1234.scope
.
The scope names embed the pid, so they are dynamic. The Id
and Name
both match the unit name exactly.
Does systemd offer any way to write a .scope
unit file that will apply [Scope]
properties to all instances of the scope by name pattern matching it, or is this something that can only really be done with the cooperation of the launching app?
Details/related at: Applying systemd control group resource limits automatically to specific user applications in a gnome-shell session
Drop-in files seem to allow this kind of override. See
man systemd.unit
or this documentation, cited below. I think the key functionally which will allow the drop-in to apply while ignoring the dynamic part (PID) is:I was able to create such an override for the user slice using the following (note the lack of PID after the last dash):
Which open a file editor where you can add your extra options. For example:
You can confirm the presence of the drop-in using:
For the system slice the approach is likely similar, except for the the
--user
flag passed tosystemctl
.