我可以限制正在运行的进程的CPU百分比以及它当前和未来的所有子进程可以使用的组合吗?我听说过这个cpulimit
工具,但这似乎忽略了子进程.
编辑:所以,我发现的答案需要cpulimit
不断运行,直到我们希望限制保持有效,因为它通过主动发送暂停然后继续向进程发送信号来进行限制.是否有其他方法可以实现这种限制效果,也许不需要在后台运行这样的辅助过程?
是!
就像我写这个问题一样,发现我正在尝试旧版本的cpulimit
.
该新版本支持限制的子进程了.
$ 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>.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1454 次 |
最近记录: |