Last active
January 18, 2017 11:13
-
-
Save arsham/95cc37359b6450b0577b9828d2f53599 to your computer and use it in GitHub Desktop.
Wroking with cgroups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from here: https://wiki.archlinux.org/index.php/cgroups | |
# You need: libcgroup and cgmanager apps. | |
# Then start the daemon: | |
sudo systemctl start cgmanager.service | |
# Creating the group | |
sudo cgcreate -a arsham:users -t arsham:users -g memory,cpu:GROUP_NAME | |
# To create subgroups | |
sudo cgcreate -a arsham:users -t arsham:users -g memory,cpu:GROUP_NAME/SUB_GROUP_NAME | |
# Limiting memory | |
echo 100000000 > /sys/fs/cgroup/memory/GROUP_NAME/memory.limit_in_bytes | |
# Limiting CPU shares | |
echo 1 > /sys/fs/cgroup/cpu/GROUP_NAME/cpu.shares | |
# Running an app in the group | |
cgexec -g cpu,memory:GROUP_NAME APP_NAME | |
# Deleting the group | |
sudo cgdelete -g memory,cpu:GROUP_NAME | |
# If you already have a subgroup be sure to remove the subgroup first | |
sudo cgdelete -g memory,cpu:GROUP_NAME/SUB_GROUP_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment