Linux ETC

CPU 사용률 제한

2015.09.18 03:40

호스트웨이 조회 수:7447

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


감사합니다.



번호 제목 글쓴이 날짜 조회 수
386 잘못푼 압축파일(tar.gz) 지우는 방법 호스트웨이 2012.12.06 3509
385 cdp 백업 프로세스 관련 호스트웨이 2015.09.07 3516
384 sftp 서비스 막기 호스트웨이 2012.12.27 3546
383 우분투 서버에 JDK7 설치하기 호스트웨이 2015.09.13 3718
382 2015년 7월1일 윤초 발생 관련 점검 방안 file 호스트웨이 2015.06.30 3887
381 리눅스 whereis 명령어 file 호스트웨이 2012.09.28 3893
380 현재 접속 사용자(머신/디바이스)수 알아내기 호스트웨이 2012.11.16 3967
379 Log file 주기적으로 정리하기 호스트웨이 2015.09.08 4047
378 queryperf 설치 및 사용 방법 (DNS 스트레스 테스트) 호스트웨이 2012.11.29 4113
377 locate 명령어를 이용해 빠르게 지정한 파일 찾기 file 호스트웨이 2012.12.11 4166
376 kbd_mode 명령어를 통해 인식중인 키보드모드 출력 및 변경하기 file 호스트웨이 2012.11.06 4175
375 Linux vmstat 명령어 호스트웨이 2015.09.08 4234
374 특정 파일이 소속된 rpm 패키지 찾기 호스트웨이 2012.12.14 4239
373 arch 명령어를 통해 컴퓨터 종류 알기 file 호스트웨이 2012.11.16 4243
372 리눅스 free 명령어 호스트웨이 2012.12.26 4291
371 limits.conf 설명 file 호스트웨이 2012.11.08 4587
370 /proc 디렉터리내 파일 정보 알아보기 호스트웨이 2012.11.21 4590
369 free -m 에서 free (남는 메모리 양) 최소량 제한하기 호스트웨이 2012.12.20 4651
368 리눅스 시스템상에서 하드웨어사양 확인 호스트웨이 2012.10.24 4717
367 vim fileformat 변경하기: -bash: ./LINUX_03.sh: /bin/sh^M: bad interpreter: No such file or directory 호스트웨이 2012.11.29 4722