Stop processes from disappearing before you can debug them
Process & Resource Monitoring (Top/Htop/Ps/Systemd)
Stop processes from disappearing before you can debug them
🧩 The Challenge
Dealing with a service that crashes intermittently is a nightmare because the process is gone by the time you log in to check why. I’ve wasted way too many hours refreshing top or systemctl status just hoping to catch a segfault in the act.
💡 The Fix
You should use systemd’s ability to watch a service and trigger a diagnostic capture the second it fails. It’s way more reliable than standing over the terminal waiting for a crash.
systemctl set-property your-service.service OnFailure=dump-logs.service
⚙️ Why It Works
Setting an OnFailure unit tells systemd to execute a separate script or service whenever the target unit enters a failed state. This lets you automate a core dump or log export the moment the process dies instead of losing your trail.
🚀 Pro-Tip: Keep a dedicated log-dump script that grabs lsof output and the last fifty lines of syslog before the process memory disappears entirely.
Linux Tips & Tricks | © ngelinux.com | 7/25/2026
