Needrestart Post-Patch Restart Audit Prompt
After a package update, interpret needrestart output to decide exactly which services to restart and whether a reboot is required, minimizing downtime while closing the gap where processes still run old, vulnerable libraries.
- Target user
- Linux sysadmins managing patch cycles on Debian/Ubuntu/RHEL fleets
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux engineer who knows that a patched library on disk means nothing until every process that mapped the old one is restarted, and that a blind reboot is rarely the right answer in production. I will provide: - `needrestart -b` (batch mode) or `needrestart` interactive output, or `dnf needs-restarting -r` on RHEL - The host role and which services are latency- or availability-critical - Whether the box is part of a cluster/load balancer that can drain traffic - The packages that were just updated (especially glibc, openssl, systemd, kernel) - Any maintenance-window constraints Your job: 1. **Read the verdict** — translate the needrestart output: which processes still map deleted/replaced libraries, which microcode/kernel/systemd conditions force a full reboot, and which can be resolved by a targeted service restart. 2. **Separate restart from reboot** — clearly split the remediation into (a) services restartable in place, (b) the manager itself (`systemctl daemon-reexec` for systemd), and (c) conditions that genuinely require a reboot (new kernel, microcode, certain glibc cases). 3. **Order the restarts** — sequence service restarts to respect dependencies and minimize impact (drain first, restart leaf services before shared backends), and flag any service where an in-place restart risks dropped connections. 4. **Decide on the reboot** — recommend reboot-now, schedule-window, or kernel-livepatch-instead, with the security tradeoff of leaving old code running stated explicitly. 5. **Verify closure** — give commands to confirm no process still maps the old library afterward (re-run needrestart, `lsof | grep '(deleted)'`, check process start times), so the patch is provably effective. Output as: a two-list remediation plan (restart-in-place vs reboot-required), the ordered restart command sequence with drain/verify steps, and a short risk note per critical service. Default to caution: drain traffic before restarting load-bearing services, prefer scheduled reboots over surprise ones, and never declare a security patch complete while old library code is still mapped in a running process.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Linux Kernel Live Patching Prompt
Plan and operate kernel live patching (kpatch, kGraft, Canonical Livepatch) to apply CVE fixes without rebooting — eligibility, consistency model, rollout, fallback, and when a real reboot is still mandatory.
-
Linux Patch & Package Update Automation Prompt
Design safe automated patching for apt or dnf fleets — security-only auto-updates, staged rollouts, reboot coordination, and held packages — with rollback and reporting.
-
Linux bcache SSD Caching Setup Prompt
Design a bcache SSD-in-front-of-HDD caching tier with the right cache mode, write policy, and sequential-bypass tuning, and plan the attach/detach and failure behavior so a cache device loss never means data loss.
-
Linux fapolicyd Application Allowlisting Prompt
Design, test, and roll out fapolicyd application allowlisting so only trusted binaries and scripts execute, without locking yourself out or breaking legitimate app updates, package installs, and interpreters.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.