2

How would I add entire session to a cgroup.

cgclassify seems to add just the specified PID.

Šimon Tóth
  • 8,238

1 Answers1

0

I have to do it with a script that does something like this:

pidtree=
pidtree() {
  local _pid=$1
  for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
    pidtree ${_child}
  done
  pidlist=$(ls -1 /proc/${_pid}/task)" $pidlist"
}
pidtree $1
cgcreate -g cpu:/job$1
cgclassify -g cpu:/job$1 $pidlist
raines
  • 284
  • Do you know anyhow that does the same script also work for cgroups-v2 too? I am trying to do the similar thing to in cgroups-v2. Does the same commands (i.e. cgcreate etc.) are still valid for cgroups-v2? Thanks. –  Mar 17 '22 at 15:29