요청한 세부 정보가없는 경우 ...
우분투에서 cgroup을 사용하는 방법은 다음과 같습니다.
이 게시물 전체에서 변수 "$ USER"를 프로세스를 실행하는 사용자로 변경해야합니다.
메모리에 대한 정보를 추가했지만 FAQ가 될 것입니다. 필요하지 않은 경우 사용하지 마십시오.
1) 설치 cgroup-bin
sudo apt-get install cgroup-bin
2) 재부팅하십시오. cgroups는 이제/sys/fs/cgroup
3) 사용자 (프로세스 소유자)를위한 cgroup을 만듭니다.
# Change $USER to the system user running your process.
sudo cgcreate -a $USER -g memory,cpu:$USER
4) 사용자가 리소스를 관리 할 수 있습니다. 기본적으로 사용자는 1024 CPU 단위 (공유)를 얻으므로 약 10 % CPU로 제한하기 위해 메모리는 바이트 단위입니다 ...
# About 10 % cpu
echo 100 > /cgroup/cpu/$USER/cpu.shares
# 10 Mb
echo 10000000 > /cgroup/memory/$USER/memory.limit_in_bytes
5) 프로세스 시작 (exec를 cgexec로 변경)
# -g specifies the control group to run the process in
# Limit cpu
cgexec -g cpu:$USER command <options> &
# Limit cpu and memory
cgexec -g memory,cpu:$USER command <options> &
구성
cgroups가 당신을 위해 일하고 있다고 가정합니다.)
편집 /etc/cgconfig.conf하고 커스텀 cgroup에 추가하십시오.
# Graphical
gksudo gedit /etc/cgconfig.conf
# Command line
sudo -e /etc/cgconfig.conf
cgroup에 추가하십시오. 프로세스를 소유 한 사용자 이름으로 $ USER를 다시 변경하십시오.
group $USER {
# Specify which users can admin (set limits) the group
perm {
admin {
uid = $USER;
}
# Specify which users can add tasks to this group
task {
uid = $USER;
}
}
# Set the cpu and memory limits for this group
cpu {
cpu.shares = 100;
}
memory {
memory.limit_in_bytes = 10000000;
}
}
그룹을 지정할 수도 있습니다 gid=$GROUP. /etc/cgconfig.conf는 주석이 잘 달렸습니다.
이제 다시 프로세스를 실행하십시오. cgexec -g cpu:$USER command <options>
PID로 프로세스를 볼 수 있습니다. /sys/fs/cgroup/cpu/$USER/tasks
예
bodhi @ ufbt : ~ $ cgexec -g cpu : 보디 수면 100 &
[1] 1499
bodhi @ ufbt : ~ $ 고양이 / sys / fs / cgroup / cpu / bodhi / tasks
1499
자세한 내용은 http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/를 참조하십시오.