1 | # yum install cpulimit |
1. 先了解一下cpulimit的参数
1 2 3 4 5 6 7 8 9 10 11 12 | # cpulimit -h Usage : cpulimit [ OPTIONS . . . ] TARGET OPTIONS – l , — limit = N percentage of cpu allowed from 0 to 100 ( required ) //cpu限制的百分比 – v , — verbose show control statistics //显示版本号 – z , — lazy exit if there is no target process , or if it dies //如果限制的进程不存在了,则退出。 – i , — include – children limit also the children processes //包括子进程。 – h , — help display this help and exit //帮助,显示参数 TARGET must be exactly one of these : – p , — pid = N pid of the process ( implies – z ) //进程的pid – e , — exe = FILE name of the executable program file or path name //可执行程序 COMMAND [ ARGS ] run this command and limit it ( implies – z ) |
2. 根据进程ID限值
1 | # cpulimit -p 1234 -l 40 |
此命令的含义为,限制pid号为1234的进程,最高只能使用40%的cpu。
3. 根据进程路径限制
1 | # cpulimit -e /usr/local/nginx-1.4.1/sbin/nginx -l 50 |
限制nginx程序只能使用最高50%的cpu。
文章转载来自:trustauth.cn