CentOS 7下CPULimit的部署與使用途中
部署
git clone https://github.com/opsengine/cpulimit.git cd cpulimit make cp src/cpulimit /usr/bin
輸入cpulimit,查看使用方式
#選項 -l 0~200 限定CPU占據率0%~200% -v 顯現控制的統計信息 -z 當被控制的程式退出的時候,CPULimit程式也跟着退出 -i 同時限定被控程式的子進程 #command -p 被控程式的PID -e 被控程式的程式稱號
舉例,譬如要限定php-fpm進程的CPU使用率最高為50%,並顯現控制信息
cpulimit -l 50 -i -v -e php-fpm
依據需要挑選能否進入 -z 參數
如果需要后台執行,只需要在command前后進入nohup……&,回車便可
#nohup command & nohup cpulimit -l 50 -e php-fpm -i -v &
參考資料:https://scoutapm.com/blog/restricting-process-cpu-usage-using-nice-cpulimit-and-cgroups