How to use cgroup in ubuntu 13.04
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:
-
Installed
cgroup
:sudo apt-get install cgroup-bin
reboot
-
Make a
cgroup
for your user (the owner of the process):sudo cgcreate -a ipeacocks -g cpu:ipeacocks
-
Ran the command:
echo 100 > /sys/fs/cgroup/cpu/ipeacocks/cpu.shares
-
And the command:
cgexec -g cpu:ipeacocks stress --cpu 4
and output:
cgroup change of group failed
Why? What I am doing wrong?
Solution 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