Process & Resource Monitoring (Top/Htop/Ps/Systemd)
Stop letting your background processes vanish into the void
🧩 The Challenge
Everyone has had a background task dump core or silently die when they weren’t looking, leaving you to guess what happened three hours later. You come back to a terminal, the shell prompt is back, and you have absolutely zero clue why your heavy lifting job stopped mid-stream.
💡 The Fix
Use systemd-run to wrap those one-off manual tasks into transient units so you can actually monitor them after you disconnect. It keeps the process alive and gives you a standard interface to check status.
systemd-run --user --scope -p MemoryMax=500M -p CPUWeight=500 ./my-massive-script.sh
⚙️ Why It Works
By creating a transient cgroup scope, systemd keeps track of the process tree even after your login session closes. You can then query the job status just like any other system service using systemctl.
🚀 Pro-Tip: Run journalctl –user -u $(systemd-run –user -p Slice=background.slice ./script.sh | grep -o ‘run-[^.]*’) to instantly filter logs for just that specific execution.
Linux Tips & Tricks | © ngelinux.com | 7/21/2026
