How to run cgexec without sudo as current user on Ubuntu 22.04 with cgroups v2, failing with "cgroup change of group failed"?
I've tried the procedures from:
- Cgroups error: cgroup change of group failed
- How to use cgroup in ubuntu 13.04
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
cgroup change of group failed
It works if I run with
sudo cgexec -g memory:myGroup id
but then the command runs as
root, and I want it to run as the current user instead.