Linux ETC

CPU 사용률 제한

2015.09.18 03:40

호스트웨이 조회 수:7206

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 kornet SMTP 서비스 종료에 따른 구글 SMTP 활용 방안 file 호스트웨이 2016.04.28 13258
385 extundelete tool을 이용하여 삭제된 파일 복구하기 호스트웨이 2016.02.29 17356
384 Login 실패시 계정 잠그기 및 PAM 설정 file 호스트웨이 2016.01.04 35093
383 fdisk 명령어를 이용하여 수동으로 파티션 나누기 file 호스트웨이 2015.11.30 62933
382 SFTP 퍼미션 조정 및 chroot 설정으로 상위폴더 접근 제한하기 호스트웨이 2015.10.29 37479
381 리눅스 CD로 손상된 파일 복구하기 호스트웨이 2015.09.29 17515
380 find 명령을 통한 소유자, 백도어, 파일 찾기 호스트웨이 2015.09.29 14859
379 Linux 설치된 OS 커널의 Bit확인 호스트웨이 2015.09.26 14548
378 SYN_Flooding 공격 막기 호스트웨이 2015.09.25 10919
377 Linux ssh 무작위 공격 방어하기 - fail2ban 호스트웨이 2015.09.24 13510
376 사용 가능한 쉘 확인 및 변경법 호스트웨이 2015.09.24 15388
375 삭제된 파일 복구 - 2 호스트웨이 2015.09.24 12583
374 프로그램의 사용 메모리 확인 호스트웨이 2015.09.23 11428
373 사용하지 않는 데몬 끄기 호스트웨이 2015.09.23 11658
372 리눅스 서버 보안 관련 설정 호스트웨이 2015.09.23 13055
371 서버시간 매시간마다 동기화 설정 호스트웨이 2015.09.23 15732
370 리눅스 상에서 메모리 사용 현황 확인하기 호스트웨이 2015.09.23 11027
369 터미널 접속 시 한글이 깨질 때 호스트웨이 2015.09.23 11180
368 서버 계정을 다른서버로 이전하기 호스트웨이 2015.09.23 16749
367 동일 네트워크의 중복 IP검색 호스트웨이 2015.09.23 15555