我能否限制正在运行的进程及其所有当前和 future 子进程可以使用的 CPU 百分比?我听说过 cpulimit
工具,但它似乎忽略了子进程。
编辑 所以,the answer我发现需要 cpulimit
持续运行,直到我们希望限制保持有效,因为它通过主动发送挂起然后继续信号到进程来进行限制。是否有其他方法可以实现这种限制效果,也许不需要在后台运行这样的辅助进程?
最佳答案
是的!
就在我写这个问题的时候,发现我正在尝试旧版本的cpulimit
。
new version也支持限制子进程。
$ 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>.
关于linux - 限制允许使用进程树的 CPU 百分比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31623697/