Skip to content

Instantly share code, notes, and snippets.

@mydreambei-ai
Created August 5, 2016 09:41
Show Gist options
  • Save mydreambei-ai/f40523ef1eb0311ded52d48e5a55a388 to your computer and use it in GitHub Desktop.
Save mydreambei-ai/f40523ef1eb0311ded52d48e5a55a388 to your computer and use it in GitHub Desktop.
create cgroup limit process

Limit Program Memory By Cgroup

  1. cgcreate -g memory:/myGroup
  2. echo $(( 500 * 1024 * 1024 )) > /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes(notes: centos cgroup mount on /sys/fs/cgroup)
  3. echo '@<username>:<command> memory /myGroup' >> /etc/cgrules.conf
  4. systemctl restart cgred
  5. cgget -g memory /myGroup (查看/myGroup的配置,以及内存使用情况)
  6. cat /proc/<pid>/cgroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment