Short answer
- Automate security updates from your distribution's security repository: unattended-upgrades on Debian and Ubuntu, dnf-automatic on RHEL, AlmaLinux and Rocky.
- Treat kernel, glibc and systemd updates as reboot events, and either schedule the restart in an announced maintenance window or bridge the gap with livepatch.
- Run needrestart after every update to see which services still hold old libraries in memory, then restart exactly those.
- Apply changes to a staging copy first, and never patch containers in place: rebuild the image and roll it out.
- Debian / Ubuntu
- unattended-upgrades, security origin only
- RHEL / Alma / Rocky
- dnf-automatic with upgrade_type = security
- Needs a full reboot
- kernel, glibc, systemd
- Check after updating
- needrestart -b
Why security patches are automatic and everything else is not
A distribution's security repository holds fixes only, with no new features, so the risk of breaking your application is small and the risk of skipping them is large. Let them run daily without anyone clicking. A new major version of PHP, PostgreSQL or Node.js is different: it is an application change that deserves staging, a date and a note in the change log. On Debian and Ubuntu the line between the two sits in Allowed-Origins; on RHEL it is upgrade_type = security. Automatic security fixes plus manual feature upgrades is the compromise that holds up.
Kernels, reboots and the maintenance window
A kernel patch that is installed but not booted protects nothing: the old kernel keeps running until the next restart. The same goes for glibc, which almost every process loads. needrestart lists the services that still map replaced libraries and tells you whether a full reboot is due. Schedule that reboot for a quiet hour, tell your customers, and check afterwards that every service came back. If you truly cannot reboot, Ubuntu Livepatch or kpatch on RHEL applies some kernel fixes in memory. With two servers behind a load balancer, reboot one at a time.
- Take a snapshot or backup before every maintenance window
- Run updates on staging at least a day before production
- Rebuild containers from an updated base image instead of patching them from inside
What Romanian regulation expects
For entities registered with DNSC under OUG 155/2024, the Romanian transposition of NIS2 approved by Law 124/2025, vulnerability handling is part of the minimum risk-management measures, and after an incident you will be asked when the patch was published and when you applied it. For any company that processes personal data, a server breached through a flaw that had been fixed for months is hard to defend before ANSPDCP under GDPR Article 32. The log that unattended-upgrades writes on its own is the simplest evidence you can keep.
Update types and how to treat them on a production server| Update type | How it is applied | Restart needed | Staging first |
|---|
| Security patch for packages | Automatic, daily | Only the affected service (needrestart) | Optional |
|---|
| Kernel, glibc, systemd | Automatic, with a planned reboot | Full reboot or livepatch | Recommended |
|---|
| New version of PHP, PostgreSQL, Node.js | Manual, planned | The service | Mandatory |
|---|
| Docker image | Rebuild in CI and roll out | The container is replaced | Mandatory |
|---|
Commands and configuration
Debian / Ubuntu: security updates only, with a planned reboot# /etc/apt/apt.conf.d/50unattended-upgrades (fragment)
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
};
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:30";
# /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
RHEL / Alma / Rocky: dnf-automatic for security onlysudo dnf install -y dnf-automatic
# /etc/dnf/automatic.conf (fragment)
[commands]
upgrade_type = security
apply_updates = yes
sudo systemctl enable --now dnf-automatic.timer
Check what is pending and what needs a restartapt list --upgradable
sudo unattended-upgrade --dry-run
sudo needrestart -b
Practical examples
Online shop in Iasi on an Ubuntu VPS
Every package was current, yet the server had not rebooted in fourteen months and still ran an old kernel with known flaws. needrestart also showed PHP-FPM using a replaced library. A planned reboot at 03:00 on a Tuesday took two minutes.
Fintech start-up in Bucharest on AlmaLinux
dnf-automatic was applying every update, including a new MariaDB minor release that changed a sorting rule and broke a report. The team switched to security-only updates and now applies feature upgrades once a month, on a staging copy first.
IT outsourcing company in Cluj-Napoca with forty customer VMs
Patching customer servers by hand left some of them months behind. A weekly list of pending updates per server, plus a rule that critical fixes go out the same day, closed the gap without adding anyone to the on-call rota.
Common mistakes
- Installing the kernel patch and never rebooting, so the vulnerable kernel keeps running.
- Letting automation apply feature upgrades too, then finding out at 3 a.m. that the application no longer starts.
- Running apt upgrade inside a container and being surprised when the flaw returns after the next restart.
- Enabling automatic reboots but never checking in the morning that the services came back.
How 4hosting helps
- Hardening & Compliance sets up automatic security updates and the maintenance window. The hours come from your plan: 1 h a month from cPanel Advanced up, 1–8 h on VPS, 5–10 h on dedicated servers (depending on plan) and 10 h on GPU servers.
- You request those hours from the DevOps Services section of the client panel. They are not carried over to the next month, and extra hours are accepted and billed separately.
- CI/CD & Monitoring moves Docker image rebuilds into the pipeline and covers blue-green and canary releases, so a patched image can replace the running one without taking the site down.
Related questions
How fast must a security patch be applied?
For flaws that are being exploited right now, the same day, even with an unplanned restart. For everything else, a daily automatic run is enough. What matters is knowing which category you are in, so follow your distribution's advisories and, if you have NIS2 duties, the DNSC bulletins.
Can automatic updates break my server?
Rarely, as long as you limit them to the security repository. The real risk comes from feature upgrades applied automatically and from reboots nobody checks. Keep a snapshot before each maintenance window and a simple check in the morning that your services answer.
How do I know whether a published vulnerability affects my server?
Compare the installed version, shown by apt policy or dnf info, with the fixed version named in your distribution's advisory, which carries the CVE identifier. For a larger estate, a vulnerability scanner run on a schedule does that comparison for you.