Security updates without downtime: restarts, reboots and live patches
apt upgrade replaces files on disk. A process that started before the update keeps running the old code from memory: the old OpenSSL in nginx, the old glibc in every daemon, the old kernel until the next boot. Scanners that check the running kernel keep reporting the CVE, and attackers can still use it. needrestart and dnf needs-restarting find what still runs old code. Many services restart without dropping connections, and a planned reboot takes care of the kernel.
What needs what
| Updated | Takes effect after |
|---|---|
| a program (sshd, nginx, postgres) | restarting that service |
| a shared library (OpenSSL, glibc, zlib) | restarting every process that loaded it |
| the kernel | a reboot, or a live patch for selected fixes |
| a container image | recreating the container from the new image |
| CPU microcode | a reboot (or a late load, depending on the platform) |
Find what still runs old code
Debian and Ubuntu: needrestart. It checks which processes map deleted or replaced files and whether a newer kernel is installed:
sudo apt install needrestart
sudo needrestart -r l # list services that need a restart, change nothing
sudo needrestart -r a # restart them
sudo needrestart -b -k # machine-readable kernel status
In batch mode, NEEDRESTART-KSTA: 1 means no kernel upgrade is pending, 2 an ABI-compatible upgrade, 3 a version upgrade; 0 means needrestart could not tell. needrestart also runs after each apt operation and asks or acts according to /etc/needrestart/needrestart.conf.
RHEL, Rocky, Alma: dnf needs-restarting (package dnf-plugins-core):
sudo dnf needs-restarting -s # systemd services to restart
sudo dnf needs-restarting -r # is a reboot needed? exit code 1 if yes
No core libraries or services have been updated since boot-up.
Reboot should not be necessary.
Any system: processes with deleted files mapped.
sudo grep -l -E '\(deleted\)' /proc/[0-9]*/maps 2>/dev/null | cut -d/ -f3 | sort -u | paste -sd, | xargs -r ps -o pid,comm -p
Restart services gracefully
Many services can reload or restart without dropping connections:
- nginx:
systemctl reload nginxstarts new workers with the new configuration and lets old workers finish their requests. A reload does not load a new nginx binary; after an nginx package update, runsystemctl restart nginx, which drops open connections for a moment, or replace the binary on the fly with theUSR2signal as the nginx documentation describes. - sshd:
systemctl restart ssh(Debian, Ubuntu) orsshd(RHEL) restarts the listener. Existing SSH sessions keep running in their own processes. - PHP-FPM, Gunicorn, uWSGI, Puma: a reload starts new workers and lets old ones finish. Check that your service unit maps
reloadto the graceful signal of the server. - Databases: a restart closes all connections. Applications with a connection pool usually reconnect; plan it in a quiet hour, or use a replica.
With more than one instance behind a load balancer or reverse proxy, restart one at a time: take it out of the pool, wait until its connections finish, restart, check health, put it back.
Containers
A restarted container runs the same image. To get fixes, pull or rebuild the image and recreate the container:
docker compose pull && docker compose up -d
Compose recreates only the services whose image changed. For zero downtime, run two replicas behind a proxy that health-checks them, and update one at a time.
Reboots
Plan them; do not wait for them to become urgent.
A fixed window. For example once a week at night for servers that can take a minute of downtime. Let the system reboot itself only when needed:
# Debian, Ubuntu: /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:30";
# RHEL family: /etc/dnf/automatic.conf
[commands]
reboot = when-needed
The defaults are off: "false" on Debian 12, never on Rocky Linux 9.
Rolling reboots. For several servers, reboot one at a time, wait until it is healthy, then the next.
Live patching. Ubuntu Livepatch (part of Ubuntu Pro, which Canonical offers free for up to five machines) and kpatch on RHEL apply fixes for selected kernel CVEs to the running kernel; Red Hat ships live patches for Critical and Important CVEs. They cover only selected fixes and do not replace reboots.
After a reboot, check that the new kernel runs (uname -r), that services came back (systemctl --failed) and that the application answers.
Make it measurable
- Check daily whether a reboot is pending, and how long it has been pending. A kernel fix that waited 40 days for a reboot did not protect anyone for 40 days.
- Count services with old libraries after each update run.
- Treat "the fix is installed but not active" as open in your tracking, not as done.
Sources
- needrestart and its batch mode description (kernel status values 0 to 3) and Debian wiki: UnattendedUpgrades
- dnf-plugins-core: needs-restarting and dnf-automatic (
reboot = when-needed) - nginx: controlling nginx (reload and graceful worker shutdown)
- Ubuntu USN-6859-1 (Ubuntu Pro free for up to five machines)
- needrestart 3.6 tested in
debian:bookworm-20261027-slim;dnf needs-restarting, dnf-automatic defaults andrebootoptions read inrockylinux/rockylinux:9.9.20261112.0, on 2026-11-26
Check your servers every day
The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.