cgset
Set control group parameters
SYNOPSIS
cgset [-r] [-v] [-h] [-t task | -P] [-g controllers:path] parameter=value ... [pid|tid]
PARAMETERS
-g controllers:path, --cg controllers:path
Specify controllers and cgroup path explicitly
-h, --help
Display help message and exit
-P, --path
Interpret argument as cgroup path (deprecated)
-r, --recursive
Set parameter recursively in all subgroups
-t task, --task=task
Set parameter for specific task ID instead of current process
-v, --verbose
Enable verbose output
DESCRIPTION
The cgset command is a tool from the libcgroup package used to configure parameters within Linux control groups (cgroups), primarily for version 1. Cgroups allow resource limiting, prioritization, and accounting for processes. cgset modifies controller-specific parameters like CPU shares, memory limits, or I/O priorities for a specified cgroup or task.
It supports setting values recursively across subgroup hierarchies or directly on process IDs (PIDs) or thread IDs (TIDs). Common use cases include tuning resource allocation for containers, batch jobs, or services to prevent resource hogging. For example, setting higher CPU shares prioritizes a process group.
Specify parameters in the format controller.parameter=value, such as cpu.shares=2048 or memory.limit_in_bytes=1G. Without a PID, it applies to the current process's cgroup. cgset requires root privileges for most operations and interacts with the cgroup filesystem mounted under /sys/fs/cgroup.
Note that with the shift to cgroups v2, systemd tools like systemd-run or direct /sys/fs/cgroup writes are preferred, as libcgroup tools are legacy.
CAVEATS
Requires root or CAP_SYS_ADMIN; legacy for cgroups v1—use systemd tools for v2; may fail if cgroup controllers not mounted; no validation of parameter values.
EXAMPLES
cgset -r cpu.shares=1024 mygroup
cgset memory.limit_in_bytes=1073741824 1234
cgset -g cpu,memory:/system.slice/service.service blkio.weight=100
PARAMETER FORMAT
Use controller.parameter=value, e.g., cpu.cfs_quota_us=50000; check /sys/fs/cgroup/<controller>/ for available params.
HISTORY
Introduced in libcgroup ~2007 for early cgroups v1 support by Red Hat developers; widely used pre-systemd era; maintained but deprecated as kernel shifted to unified cgroups v2 in 2016+.
SEE ALSO
cgcreate(1), cgexec(1), cgclassify(1), cgrulesengd(8), systemd-run(1)


