Limit the percentage of CPU allowed for the process tree?
Can I limit the percentage of the processor in the current process and all current and future children can use it together? I've heard about the tool cpulimit
but seems to be ignoring child processes.
Edit: So, the answer I found requires that it be cpulimit
executed continuously until we want the limit to remain in effect, as it makes the limit by actively sending suspend and then continues signaling to the process. Are there possibly other ways to achieve this limiting effect, perhaps without the need for such a secondary process in the background?
source to share
Yes!
Just as I was writing this question, it turned out that I was trying an older version cpulimit
.
the new version also supports limiting child processes.
$ cpulimit -h
Usage: cpulimit [OPTIONS...] TARGET
OPTIONS
-l, --limit=N percentage of cpu allowed from 0 to 400 (required)
-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)
-e, --exe=FILE name of the executable program file or path name
COMMAND [ARGS] run this command and limit it (implies -z)
Report bugs to <marlonx80@hotmail.com>.
source to share