Linux ETC

CPU 사용률 제한

2015.09.18 12:40

호스트웨이 조회 수:3475

WEB 및 DB등 운영중인 서버에서 백업,배치등의 이유로 CPU부하가 발생 하는 경우가 있습니다.

이럴때 각 프로세에 CPU limit설정 하여 자원 확보하는 프로그램이 있습니다.


#download

- http://sourceforge.net/projects/cpulimit/files/cpulimit/cpulimit/cpulimit-1.1.tar.gz/download?use_mirror=jaist&r=&use_mirror=cdnetworks-kr-1 


#install

[root@apm ~]# ls -la |grep cpulimit-1.1.tar.gz

-rw-r--r--   1 root root    5130 Sep 18 11:41 cpulimit-1.1.tar.gz

[root@apm ~]# tar zxvf cpulimit-1.1.tar.gz

cpulimit-1.1/

cpulimit-1.1/Makefile

cpulimit-1.1/cpulimit.c

[root@apm ~]# cd cpulimit-1.1

[root@apm cpulimit-1.1]# make

gcc -o cpulimit cpulimit.c -lrt -Wall -O2

[root@apm cpulimit-1.1]# ls -la

total 48

drwxr-xr-x  2 1002 root   4096 Sep 18 11:57 .

dr-xr-x---. 5 root root   4096 Sep 18 11:57 ..

-rwxr-xr-x  1 root root  17070 Sep 18 11:57 cpulimit

-rw-r--r--  1 1002 users 14146 Jun 27  2005 cpulimit.c

-rw-r--r--  1 1002 users   107 Jun 24  2005 Makefile

[root@apm cpulimit-1.1]#


#execute
[root@apm cpulimit-1.1]# ps -ef |grep gzip
root     27155 26446 96 12:00 pts/1    00:00:30 gzip -9
root     27162 26446  0 12:01 pts/1    00:00:00 grep gzip
[root@apm cpulimit-1.1]#

./cpulimit -p 27155 -l 30 &


[root@apm cpulimit-1.1]# ps -ef |grep gzip
root     27155 26446 30 12:00 pts/1    00:37:02 gzip -9
root     28643 26446  0 12:39 pts/1    00:00:00 grep gzip

#option
[root@apm cpulimit-1.1]# ./cpulimit --h
Usage: cpulimit TARGET [OPTIONS...]
   TARGET must be exactly one of these:
      -p, --pid=N        pid of the process
      -e, --exe=FILE     name of the executable program file
      -P, --path=PATH    absolute path name of the executable program file
   OPTIONS
      -l, --limit=N      percentage of cpu allowed from 0 to 100 (mandatory)
      -v, --verbose      show control statistics
      -z, --lazy         exit if there is no suitable target process, or if it dies
      -h, --help         display this help and exit


감사합니다.



번호 제목 글쓴이 날짜 조회 수
326 vi 편집기에서 모든글자를 대소문자로 변경할때 사용하는 명령어 호스트웨이 2012.11.23 4119
325 리눅스 간단 시스템 점검 1편 호스트웨이 2012.11.14 4128
324 VNC-server 설치 및 설정 호스트웨이 2012.10.12 4151
323 리눅스 dmesg 명령어 file 호스트웨이 2012.12.06 4155
322 [ERROR] ftp error 500 OOPS: cannot change directory:/home/ 호스트웨이 2012.12.21 4276
321 rpm에서 원하는 파일만 풀어서 사용하기 호스트웨이 2015.09.19 4276
320 디렉토리(폴더) 색상 변경하기 file 호스트웨이 2015.09.08 4280
319 ngrinder를 이용한 부하 테스트 - 1) Controller 설치 file 호스트웨이 2015.04.08 4285
318 /dev/null 과 /dev/zero의 차이 file 호스트웨이 2012.10.05 4286
317 명령어 dstat 사용하기 호스트웨이 2015.09.01 4370
316 ifconfig 항목 설명 호스트웨이 2012.11.22 4399
315 리눅스 comm 명령어를 통해 두개의 파일내용 비교하기 file 호스트웨이 2012.11.29 4406
314 df 와 du의 출력 크기가 다르게 보이는 이유 호스트웨이 2012.12.14 4423
313 useradd 명령어 사용방법 및 옵션 호스트웨이 2015.09.08 4431
312 리눅스 tac 명령어를 통해 파일내용 역순으로 출력하기 file 호스트웨이 2012.10.18 4462
311 리눅스 파일명 일괄변경하기 file 호스트웨이 2012.10.18 4467
310 Block 단위 파일 복사를 위한 dd 사용 호스트웨이 2015.09.18 4514
309 서비스 체크 스크립트 호스트웨이 2012.09.28 4536
308 리소스 많이 차지하는 프로세스 찾기 호스트웨이 2015.09.20 4559
307 Kick-Start 설정 호스트웨이 2015.09.18 4589