Difference between revisions of "Cgcreate"
Jump to navigation
Jump to search
(16 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | <code>cgcreate</code> command is included in the [[cgroup-tools]] packages https://linux.die.net/man/1/cgcreate | + | {{lowercase}} |
+ | <code>cgcreate</code> command is included in the <code>[[cgroup-tools]]</code> packages https://linux.die.net/man/1/cgcreate | ||
+ | == Limit [[memory]] == | ||
+ | cgcreate -g memory:myGroup | ||
+ | echo 500M > [[/sys/fs/]]cgroup/memory/myGroup/memory.limit_in_bytes | ||
+ | echo 5G > /sys/fs/cgroup/memory/myGroup/memory.memsw.limit_in_bytes | ||
+ | [[cgexec]] -g memory:myGroup PROGRAM_TO_EXECUTE | ||
+ | |||
+ | == [[CPU]] == | ||
+ | cgcreate -g cpu:/myCpulimit | ||
+ | [[cgset]] -r cpu.cfs_period_us=1000000 myCpulimit | ||
+ | [[cgset]] -r cpu.cfs_quota_us=100000 myCpulimit | ||
+ | cgget -g cpu:myCpulimit | ||
+ | cgexec -g cpu:myCpulimit YOUR_COMMAND | ||
− | |||
+ | [[cgset]] -r cpu.AllowedCPUs=1 myCpulimit | ||
Line 25: | Line 38: | ||
== Related commands == | == Related commands == | ||
− | * [[ulimit]] | + | * <code>[[ulimit]]</code> |
+ | * <code>[[lscgroup]]</code> | ||
== See also == | == See also == |
Latest revision as of 07:27, 24 March 2023
cgcreate
command is included in the cgroup-tools
packages https://linux.die.net/man/1/cgcreate
Contents
Limit memory[edit]
cgcreate -g memory:myGroup echo 500M > /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes echo 5G > /sys/fs/cgroup/memory/myGroup/memory.memsw.limit_in_bytes cgexec -g memory:myGroup PROGRAM_TO_EXECUTE
CPU[edit]
cgcreate -g cpu:/myCpulimit cgset -r cpu.cfs_period_us=1000000 myCpulimit cgset -r cpu.cfs_quota_us=100000 myCpulimit cgget -g cpu:myCpulimit cgexec -g cpu:myCpulimit YOUR_COMMAND
cgset -r cpu.AllowedCPUs=1 myCpulimit
Controller | Can be controlled by user | Options |
---|---|---|
cpu | Yes (Requires delegation) | CPUAccounting, CPUWeight, CPUQuota, AllowedCPUs, AllowedMemoryNodes |
io | Yes (Requires delegation) | IOWeight, IOReadBandwidthMax, IOWriteBandwidthMax, IODeviceLatencyTargetSec |
memory | Yes | MemoryLow, MemoryHigh, MemoryMax, MemorySwapMax |
pids | Yes | TasksMax |
rdma | No | ? |
eBPF | No | IPAddressDeny, DeviceAllow, DevicePolicy |
Related commands[edit]
See also[edit]
Advertising: