brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: systemd-cgls -u shows every process inside one service

Systemd
~/tips/tip-systemd-cgls-unit

systemd-cgls -u nginx.service

See the full process tree of one unit, including children the main process started.

ps shows processes, but not which service started them. systemd keeps every process of a unit in its own control group, and systemd-cgls draws that tree.

Limit it to one unit with -u:

systemd-cgls -u nginx.service

For a service that runs sh -c "...; sleep 1000", the output is the unit name and its cgroup path, followed by two lines: the shell with its PID and the sleep child below it. With nginx you see the master and all workers, with PHP-FPM every pool child.

I like it for questions like whether a backup service left a stray rsync running, or which processes will get killed when you stop a unit, since systemctl stop kills everything in that group by default.

Without -u it prints the whole machine, grouped by slice:

systemd-cgls --no-pager | less

For a user’s own services, use --user-unit instead of -u. And if a process you expect is missing, it may have left the group on purpose; some daemons double fork into a different scope, or were started by hand from a shell, and then they belong to your session instead of the service.

Further reading: systemd-cgls man page

Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid

More Systemd tips [Service] sudo mkdir -p /etc/systemd/system/service.d [Service] printf 'hunter2' | sudo systemd-creds encrypt --name=dbpass – dbpass.cred systemd-analyze timespan 1h30min All Systemd tips (88) All topics

Link