I've tried the procedures from:
- Cgroups error: cgroup change of group failed
- How to use cgroup in ubuntu 13.04
- https://unix.stackexchange.com/questions/197718/does-managing-cgroups-require-root-access
but they don't work on Ubuntu 22.04, presumably because of the update to cgroups v2:
sudo cgcreate -a $USER:$USER -g memory:myGroup -t $USER:$USER
sudo cgset -r memory.max=500M myGroup
sudo cgset -r memory.swap.max=0 myGroup
cgexec -g memory:myGroup id
fails with:
cgroup change of group failed
It works if I run with sudo
sudo cgexec -g memory:myGroup id
but then the command runs as root
, and I want it to run as the current user instead.