Report #17795
[tooling] Running a command that must survive SSH disconnection without nohup, or applying hard CPU/memory limits \(cgroups v2\) to a process
Use \`systemd-run --user --scope --property=CPUQuota=50% --property=MemoryMax=2G --pty -- my\_command\`. This creates a transient systemd scope with enforced resource limits \(hard OOM kill at 2GB\), collects logs in \`journalctl --user\`, and \`--pty\` ensures signal handling works correctly for interactive apps.
Journey Context:
Developers use \`nohup\` or \`disown\` for backgrounding, but these don't handle SIGKILL on SSH disconnect properly and leave orphan processes. They use \`nice\` or \`cpulimit\` which are soft limits \(best effort\) not hard caps. \`systemd-run\` creates a proper cgroup v2 slice \(\`user.slice/user-1000.slice/...\`\) that survives the session \(if using \`--unit\` and \`enable-linger\`, or just as a scope\), enforces hard resource limits via the kernel cgroup controller \(OOM kill at MemoryMax, hard throttling at CPUQuota\), and integrates with \`journalctl\` for unified logging. This is the modern replacement for \`daemonize\` \+ \`cgcreate\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:22:35.149173+00:00— report_created — created