cgroups commands

8 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 8 shown

  • cat /sys/fs/cgroup/system.slice/<name>.service/memory.current /sys/fs/cgroup/system.slice/<name>.service/memory.max

    Live RSS vs hard limit for a systemd service; current near max = imminent OOM

    memory · performance · troubleshooting

  • cat /sys/fs/cgroup/system.slice/<name>.service/memory.pressure

    PSI: time tasks stalled on memory reclaim; rising avg10 = thrashing before OOM

    memory · performance · observability

  • grep -E 'nr_throttled|throttled_usec' /sys/fs/cgroup/system.slice/<name>.service/cpu.stat

    Count and total usec a cgroup was CPU-throttled by cpu.max quota

    cpu · performance · troubleshooting

  • cat /sys/fs/cgroup/system.slice/<name>.service/cpu.max # "max 100000" = unlimited; "50000 100000" = 0.5 core

    cpu.max is 'quota period' in usec; 'max' = no limit. note: prefer systemctl set-property

    cpu · performance

  • cat /sys/fs/cgroup/system.slice/<name>.service/io.pressure /sys/fs/cgroup/system.slice/<name>.service/io.stat

    PSI io stall plus per-major:minor rbytes/wbytes/rios; pin noisy disk neighbors

    disk · performance · observability

  • cat /sys/fs/cgroup/system.slice/<name>.service/cgroup.procs; systemctl status <name>.service | grep CGroup

    Every PID currently in the service slice; cross-check with systemctl status tree

    systemd · troubleshooting · debug

  • systemd-cgls --all --no-pager; systemd-cgtop -d 2 --depth=3

    cgls --all shows empty cgroups too; cgtop ranks slices by live CPU/mem/io

    systemd · monitoring · performance

  • cgcreate -g memory:/<name>; cgset -r memory.limit_in_bytes=512M <name>; cgexec -g memory:/<name> <command>

    libcgroup v1 throwaway limit. note: v2 unified hierarchy uses systemd-run --scope -p

    memory · systemd