3

systemd launches a process in the /system.slice/process-name.service cgroup. I would like to launch the process in a different cgroup. I can do this using cgexec in the ExecStart option, but is there a better way?

Jeff Kubina
  • 427
  • 1
  • 4
  • 14

1 Answers1

5

Creat a group-name.slice, and set the resource control configuration in the slice unit, such as, CPUShares=, MemoryLimit=.

Then set Slice=group-name.slice in the process-name.service.

See man systemd.resource-control for details.

Shuangistan
  • 166
  • 3
  • At this point, in ubuntu 20.04, no need to create `group-name.slice` before set it in `process-name.service`, seems `systemd` can create by it self – DeamonMV Aug 08 '23 at 13:57