Linux: limit CPU usage by running process

Use cpulimit for this.

We have a 8-core CPU (it means the total CPU usage can be 800%, and 100% for 1 core respectively).
Our process is ‘raid-check’.

/usr/bin/cpulimit --exe /usr/sbin/raid-check --limit 600

I added this line to crontab config. The reason is that my Asterisk stops accepting calls when the CPU load is too high. Of course you can also use asterisk.conf settings to achieve the desired results.


[root@voip-ge ~]# cat /etc/cron.d/raid-check
# Run system wide raid-check once a week on Sunday at 1am by default
0 1 * * Mon root /usr/sbin/raid-check

# limit the CPU usage by executable name
1 1 * * Mon root /usr/bin/cpulimit --exe /usr/sbin/raid-check --limit 600

Tags:

Comments are closed.