关于linux运维:Linux系统使用cpulimit对CPU使用率进行限制
介绍cpulimit 是一个限度过程的 CPU 使用率的工具(以百分比示意,而不是以 CPU 工夫示意)。 当不心愿批处理作业占用太多 CPU 时,管制批处理作业很有用。 指标是避免过程运行超过指定的工夫比率。 它不会更改 nice 值或其余调度优先级设置,而是更改实在的 CPU 使用率,而且可能动静且疾速地适应整个零碎负载。 应用的 CPU 数量的管制是通过向过程发送 SIGSTOP 和 SIGCONT POSIX 信号来实现的。 指定过程的所有子过程和线程将共享雷同百分比的 CPU。 源装置【举荐】Centos: yum install cpulimitDebian / Ubuntu: apt-get install -y cpulimit`编译装置cd /tmpwget 'https://sunpma.com/other/oss/cpulimit-1.1.tar.gz'tar cpulimit-1.1.tar.gzcd cpulimit-1.1makecp cpulimit /usr/local/sbin/rm -rf cpulimit*应用实例限度程序名为 xmrig的程序仅应用 60%的CPU使用率,并在后盾始终运行; cpulimit -e xmrig -l 60 -b限度过程号为 10086的程序仅应用 60%的CPU利用率,并在后盾始终运行; cpulimit -p 10086 -l 60 -b限度绝对路径下的软件仅应用 60%的CPU利用率,并在后盾始终运行; cpulimit -e /usr/local/nginx/sbin/nginx -l 60 -b敞开cpulimit后盾过程(勾销所有限度) kill $(pidof cpulimit)应用办法-p--pid=Npid of the process过程的PID-e--exe=FILEname of the executable program file可执行程序文件名-P--path=PATHabsolute path name of the过程的绝对路径名-b--backgroundrun in background后盾运行-l--limit=Npercentage of cpu allowed from 1 up容许的CPU百分比,最低为1%-z--lazyexit if there is no suitable target process如果指标过程退出或无指标过程则终止-h--helpdisplay this help and exit显示帮忙并退出注意事项限度CPU的百分比依照理论的CPU数量而定,比方单核最高为100%,双核最高为200%,三核最高为300%,以此类推即可;ROOT用户能够限度所有的过程,普通用户只能限度用户有权限治理的过程;以上就是 cpulimit 这个小工具的一些根底用法和进阶用法,心愿对大家有所帮忙。 ...