Linux ETC

CPU 사용률 제한

2015.09.18 12:40

호스트웨이 조회 수:3485

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 dmidecode 명령 jook 2009.10.30 32171
325 도메인 / IP 정보 조회 방법 및 사이트 Namlyong 2010.01.13 32348
324 hdparm 옵션 알아보기 sylee 2010.02.04 24244
323 반복적인 수행 crontab - 기본편 Namlyong 2010.04.02 24734
322 vsftpd 시간이 맞지 않을때 sylee 2010.04.07 20172
321 리눅스에서 mii-tool 사용 방법 호스트웨이 2012.03.08 22594
320 DHCP 환경에서의 resolv.conf 초기화 현상 호스트웨이 2012.03.09 23635
319 SSH 패스워드 없이 자동 로그인 하는 방법 호스트웨이 2012.03.09 18097
318 리눅스 서버 누가 언제 무슨 작업을 했는지 확인 방법 호스트웨이 2012.03.09 93573
317 데비안 백포트 사용해 보기 호스트웨이 2012.03.16 18248
316 grep 명령어 사용하기 file 호스트웨이 2012.03.16 19215
315 비대해진 로그 파일 내용을 비우는 방법 - /dev/null 호스트웨이 2012.03.16 61428
314 history 조회시 '날짜,시간' 표시하기 호스트웨이 2012.03.16 49666
313 at 명령어를 이용한 예약 작업 호스트웨이 2012.03.16 21870
312 scp 명령어를 이용한 파일 복사 및 전송 호스트웨이 2012.03.16 264811
311 yum repository 국내 mirror 설정 file 호스트웨이 2012.03.23 36965
310 vsftp사용 시 root 계정 이용하기 file 호스트웨이 2012.03.23 18503
309 OSI 7 Layer 의 이해 file 호스트웨이 2012.03.23 18322
308 포트를 사용중인 프로세스 확인하기 file 호스트웨이 2012.03.23 19225
307 VSFTP 에서 사용하는 port를 변경하기 호스트웨이 2012.03.23 39734