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


감사합니다.



번호 제목 글쓴이 날짜 조회 수
366 삭제된 파일 복구 - 1 호스트웨이 2015.09.23 9167
365 리눅스 터미널 기반 모니터링 툴 "glances" 호스트웨이 2015.09.23 7812
364 Linux 파일명이 깨진파일 삭제 호스트웨이 2015.09.23 17627
363 mknod_장치파일을 만들어 사용 호스트웨이 2015.09.22 6500
362 /etc/fstab 등록 호스트웨이 2015.09.22 11124
361 /proc/sys/net/ipv4/conf/ 네트워크 세팅 호스트웨이 2015.09.22 9765
360 /proc/sys/net/ipv4 활용 서버보안 -3- 호스트웨이 2015.09.22 7149
359 사용하고 있던 외장하드가 마운트 되지 않는 경우 호스트웨이 2015.09.22 6459
358 filezilla 디렉토리 목록 조회 실패 호스트웨이 2015.09.22 8564
357 /dev/null 복구 호스트웨이 2015.09.21 7058
356 모든 파일 안의 문자열 치환하기 호스트웨이 2015.09.21 3964
355 Linux -(하이픈)으로 시작하는 파일 지우기 호스트웨이 2015.09.20 5514
354 서버 네트워크 대역폭 제한 호스트웨이 2015.09.20 5720
353 리소스 많이 차지하는 프로세스 찾기 호스트웨이 2015.09.20 4562
352 Touch 파일 용량 0바이트 만들기 호스트웨이 2015.09.20 6120
351 tar 분할압축하기 호스트웨이 2015.09.19 5880
350 rpm에서 원하는 파일만 풀어서 사용하기 호스트웨이 2015.09.19 4280
349 Linux chkrootkit을 이용한 백도어 설치 탐지 호스트웨이 2015.09.18 5940
348 dumpe2fs - 파일시스템 상세 정보 확인 호스트웨이 2015.09.18 5612
347 Proftp 설치 및 xinetd 에서 실행하기 file 호스트웨이 2015.09.18 5590