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 읽기 전용 파티션 읽고 쓸수 있게 재마운트하는 방법 호스트웨이 2015.09.13 2718
325 vsftpd 패시브 모드 설정 호스트웨이 2015.09.13 3345
324 우분투 서버에 JDK7 설치하기 호스트웨이 2015.09.13 1360
323 리눅스 파일 및 디렉토리 권한 관리 file 호스트웨이 2015.09.13 5184
322 root 초기 접속 홈디렉토리 변경하기 호스트웨이 2015.09.12 7037
321 Linux 외장 저장장치 mount file 호스트웨이 2015.09.10 1397
320 SNMPD LOG 안남게 하기 호스트웨이 2015.09.10 2891
319 XFS 파티션 설치 및 마운트 (CentOS 기준) 호스트웨이 2015.09.09 25387
318 UTF-8 환경의 Linux 에서 SAMBA 한글 인코딩 문제 해결 방법 호스트웨이 2015.09.09 3288
317 500 FTP server shut down 문제 해결 호스트웨이 2015.09.09 2401
316 Linux vmstat 명령어 호스트웨이 2015.09.08 1094
315 useradd 명령어 사용방법 및 옵션 호스트웨이 2015.09.08 4436
314 linux 특정 용량으로 파일을 찾기, 삭제하기 호스트웨이 2015.09.08 4693
313 apache log rotatelogs 관리 호스트웨이 2015.09.08 3787
312 디렉토리(폴더) 색상 변경하기 file 호스트웨이 2015.09.08 4297
311 리눅스 파일 소유자, 권한 일괄 변경하기 호스트웨이 2015.09.08 7770
310 Log file 주기적으로 정리하기 호스트웨이 2015.09.08 1644
309 UTF-8 환경에서 리눅스 한글 꺠짐 현상 해결법 호스트웨이 2015.09.08 2771
308 리눅스 UTF-8 언어 설정 호스트웨이 2015.09.07 27618
307 cdp 백업 프로세스 관련 호스트웨이 2015.09.07 1007