How to see cgroup in ps output
How to see cgroup in ps output?
Run the ps command and select the columns 'pid' and 'cgroup' by using the option -o.
ps -e -o pid,cgroup:64,argsThe ps command can show the control group of a process using the -o option, followed by the right column names.
Usage
To show processes and the control group, we can filter the output columns.
# ps -e -o pid,cgroup:64,args
PID CGROUP COMMAND
1 0::/init.scope /lib/systemd/systemd --system --deserialize 58
2 - [kthreadd]
3 - [rcu_gp]
<snip>
576 - [xprtiod]
634 0::/system.slice/dbus.service @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
640 0::/system.slice/networkd-dispatcher.service /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
645 - [nfsiod]
653 0::/system.slice/systemd-logind.service /lib/systemd/systemd-logind
696 0::/system.slice/system-getty.slice/getty@tty1.service /sbin/agetty -o -p -- \u --noclear tty1 linux
In this example the PID is displayed, with the control group, and the command with its arguments. By specifying the width of 64 characters, we can properly see the full name of the control group.