Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cgroups for java on Fedora
export MY_CGROUP_NAME="java_build"
export MY_SUBSYSTEMS="cpu,cpuacct"
sudo cgcreate -t $USER:$USER -a $USER:$USER -g $MY_SUBSYSTEMS:$MY_CGROUP_NAME
sudo cgset -r cpu.cfs_period_us=1000 $MY_CGROUP_NAME
sudo cgset -r cpu.cfs_quota_us=1000 $MY_CGROUP_NAME
# ls -al /sys/fs/cgroup/$MY_SUBSYSTEMS/$MY_CGROUP_NAME/
# cgexec seems not to work for me, so we are going to create explicitely a subshell and assign a cgroup to that process
bash
cgclassify -g $MY_SUBSYSTEMS:$MY_CGROUP_NAME $BASHPID
# verify it's working checking
# cat /proc/$BASHPID/cgroup
# if you want to delete the group (ignore the error)
cgdelete -g $MY_SUBSYSTEMS:$MY_CGROUP_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment