Linux command
cgexec 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
cgexec -g cpu:mygroup [command]
Example
cgexec -g cpu,memory:mygroup [command]
Example
cgexec -g cpu:mygroup -g memory:memgroup [command]
Example
cgexec --sticky -g cpu:mygroup [command]
说明
cgexec executes a process within a specified control group (cgroup). Unlike cgclassify, which moves already-running processes, cgexec starts a new process directly inside the target cgroup from the beginning. Cgroups allow limiting, measuring, and controlling resource usage by processes for CPU, memory, I/O, and other resources. By launching a process with cgexec, all resource constraints defined for that cgroup apply immediately from process startup, including any child processes it spawns. cgexec is part of the libcgroup-tools package and works with cgroups v1. For cgroups v2 systems, systemd-run provides similar functionality.
参数
- -g _controllers:path_
- Specify the controller(s) and cgroup path. Multiple controllers can be comma-separated. Can be used multiple times.
- --sticky
- Prevent cgrulesengd (cgred) from reclassifying the process or its children.
- -b
- Ignore the default systemd delegated hierarchy path and construct the cgroup path relative to the root hierarchy.
- -h
- Display help information.
FAQ
What is the cgexec command used for?
cgexec executes a process within a specified control group (cgroup). Unlike cgclassify, which moves already-running processes, cgexec starts a new process directly inside the target cgroup from the beginning. Cgroups allow limiting, measuring, and controlling resource usage by processes for CPU, memory, I/O, and other resources. By launching a process with cgexec, all resource constraints defined for that cgroup apply immediately from process startup, including any child processes it spawns. cgexec is part of the libcgroup-tools package and works with cgroups v1. For cgroups v2 systems, systemd-run provides similar functionality.
How do I run a basic cgexec example?
Run `cgexec -g cpu:mygroup [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -g _controllers:path_ do in cgexec?
Specify the controller(s) and cgroup path. Multiple controllers can be comma-separated. Can be used multiple times.