Linux ETC

CPU 사용률 제한

2015.09.18 12:40

호스트웨이 조회 수:3484

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


감사합니다.



번호 제목 글쓴이 날짜 조회 수
46 리눅스에서 NTFS 읽고 쓰기 호스트웨이 2009.04.18 32284
45 도메인 / IP 정보 조회 방법 및 사이트 Namlyong 2010.01.13 32319
44 yum 으로 패키지그룹 관리하기 jook 2009.04.22 32426
43 Privilege separation user sshd does not exist 메세지 sylee 2008.06.04 32430
42 현재 설치된 메모리 정보를 확인하는 방법 호스트웨이 2012.03.30 32477
41 SELinux 제어 방법 호스트웨이 2008.05.19 32678
40 리눅스에서 fstab을 UUID로 변경 호스트웨이 2012.08.23 32953
39 리눅스에서 fuser 명령어 사용하기 호스트웨이 2012.06.15 33505
38 데비안 기본 라이브러리 설치 호스트웨이 2008.06.03 33514
37 Fedora8, 9 버전에서 setup -> Network configuration 메뉴가 동작하지 않을때 jook 2008.07.23 34118
36 source rpm 을 사용하여 rpm 패키지 만들기 jook 2008.05.28 34281
35 multitail (다수의 파일을 tail 로 볼 수 있습니다.) HOSTWAY 2008.12.04 34475
34 shell 접속은 차단하고 ftp접속만 허용하기 sylee 2008.05.20 34494
33 리눅스 원격 접속자 세션 종료 file 호스트웨이 2012.06.08 34940
32 apt-get 간단 사용 방법 jook 2008.12.11 35261
31 parted를 이용한 2TB 이상의 partitioning file 호스트웨이 2012.05.05 35731
30 yum repository 국내 mirror 설정 file 호스트웨이 2012.03.23 36920
29 커널 파라미터 제어 호스트웨이 2008.06.25 36965
28 VNC rpm 설치해보기 sylee 2008.08.07 37739
27 yum 사용 팁 jook 2008.09.02 38919