User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
top-cpulimit.png

Usually running the nice command with the correct priority could be enough to put a process in a using cap. But, nice doesn't limit CPU use, it does only a prioritization of processes. This means the given process will run using all CPU's power if there is no other process (with higher niceness) requiring the CPU. This is not the best in some cases, I found the project Cpulimit which it does put a CPU use cap based on the percentage.

Cpulimit is a tool which limits the CPU usage of a process (expressed in percentage, not in CPU time). It is useful to control batch jobs when you don't want them to eat too many CPU cycles. The goal is to prevent a process from running for more than a specified time ratio. It does not change the nice value or other scheduling priority settings, but the real CPU usage. Also, it is able to adapt itself to the overall system load, dynamically and quickly. The control of the used CPU amount is done sending SIGSTOP and SIGCONT POSIX signals to processes. All the children processes and threads of the specified process will share the same percentage of CPU.

In my case, I need to limit the CPU use as I am running a crypto currency mining software. This kind of programs are very CPU hungry and I need to put a limit in order to don't have a useless computer. I have a 4-core CPU, and the following line will make the miner only to use 1 CPU (not really one CPU, but the sum of the effort of the four will be equivalent to one). I typed:

cpulimit -l 100 ethminer -F http://192.168.7.222:8545

After, that the top command will show you something like the image in this article. Keep in mind that the maximum value for the l parameter is 100 * n (where n is number of CPU's you have).

Enjoy!

blog comments powered by Disqus

About

Read about IT, Migration, Business, Money, Marketing and other subjects.

Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.