I'm trying to learn how cgroup works on Ubuntu and seems that cgroup doesn't work in Ubuntu 13.04. I am using the answer to this question How to set cpu limit for given process permanently. Cpulimit and nice don't work

These are what I've done:

  1. Installed cgroup:

    sudo apt-get install cgroup-bin
  2. reboot

  3. Make a cgroup for your user (the owner of the process):

    sudo cgcreate -a ipeacocks -g cpu:ipeacocks
  4. Ran the command:

    echo 100 > /sys/fs/cgroup/cpu/ipeacocks/cpu.shares
  5. And the command:

    cgexec -g cpu:ipeacocks stress --cpu 4

and output:

cgroup change of group failed

Why? What I am doing wrong?


1 Answer 1


You need to be the owner of the tasks file as well so you have permission to write a pid to it. To do that, Use -t, e.g.,

sudo cgcreate -a $USER:$USER -t $USER:$USER -g cpu:ipeacocks
  • yes, that was it. A pity I cannot mark at solved. @ipeacocks, would you?
    – Rmano
    Commented Nov 21, 2014 at 18:09
  • 1
    just to help a bit sudo cgcreate -a $USER:$USER -t $USER:$USER -g ... Commented Jul 8, 2017 at 23:45
  • I had to run additionally this command to make the error go away: chmod 711 /sys/fs/cgroup/cpu,cpuacct Commented Sep 30, 2020 at 20:18
  • Didn't work on Ubuntu 22.04 which now has cgroups v2 unfortunately: askubuntu.com/questions/1406329/… Commented May 3, 2022 at 11:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .