Linux Administration·8 min read·

Unattended Upgrades: Automated Maintenance Windows on Linux

Automate zero-touch security updates on Debian/Ubuntu with strict maintenance time windows, automated reboots, and email alerts.

NB

Netbay Cloud Team

Netbay Engineering

On this page

Unpatched vulnerabilities in operating system packages represent the single largest attack vector for Internet-facing cloud servers. Zero-day exploits against OpenSSH, glibc, and the Linux kernel often emerge with public exploit code within 48 hours of disclosure. Relying on manual administrative patching across server fleets guarantees delayed updates and exposed attack surfaces.

The unattended-upgrades framework on Debian and Ubuntu automates package installation with enterprise-grade safety. When configured correctly, it applies security-only patches, excludes volatile database and application packages, and executes reboots strictly inside predetermined maintenance windows without human intervention.

Expand
Automated Maintenance
Automated Linux Patching Architecture
Unattended Upgrades Automated Maintenance Window Workflow APT Timer Trigger Daily repository fetch Security Filter Origin matches security Package Install Blacklist exclusions applied Reboot Check /var/run/reboot-required Maintenance Window Reboot scheduled at 03:30 AM Automated reboots occur strictly at off-peak hours only when essential kernel or glibc patches require them.

Production Configuration File

Install the package and configure security repository origins, package blacklists, and automatic reboot schedules:

bash
# Install the unattended-upgrades suite
sudo apt-get update && sudo apt-get install -y unattended-upgrades update-notifier-common

Edit the core configuration file at /etc/apt/apt.conf.d/50unattended-upgrades:

ini
// /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
    "${distro_id}:${distro_codename}-security";
};

// Blacklist mission-critical packages from automated upgrades
Unattended-Upgrade::Package-Blacklist {
    "nginx";
    "postgresql.*";
    "redis.*";
    "docker-ce.*";
};

// Auto-remove unused dependency packages and kernels
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";

// Scheduled Reboot Settings
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-WithUsers "false";
Unattended-Upgrade::Automatic-Reboot-Time "03:30";

// Notifications
Unattended-Upgrade::Mail "sysadmin@example.com";
Unattended-Upgrade::MailReport "only-on-error";

Next, configure the daily execution trigger in /etc/apt/apt.conf.d/20auto-upgrades:

ini
// /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";

Dry-Run Testing and Validation

Before leaving the system in automated hands, perform a complete dry-run execution:

bash
# Simulate update processing with verbose debug logs
sudo unattended-upgrade --dry-run --debug

# Inspect historical update logs
sudo cat /var/log/unattended-upgrades/unattended-upgrades.log

The log records every package evaluated, matched against blacklist regexes, and installed, giving complete audit visibility.

Automation and Scripting Video

Learn more about automating system administration tasks in this overview:

Automated Server Patching and Administration
YouTube

Managing Kernel Reboots Safely

When an updated kernel installs, unattended-upgrades flags the system by creating /var/run/reboot-required. If Automatic-Reboot is enabled, the server checks the wall-clock time and triggers systemctl reboot at exactly 03:30 AM local time. This eliminates human negligence without causing daytime service interruptions.

Keep your cloud infrastructure always patched and secure on Netbay VPS instances at netbayhosts.in.

Keep reading

Follow along on a real VPS

Deploy Linux in under 60 seconds

These guides are written against Ubuntu, Debian, and RHEL-family images — the same ones on NetBay.

Deploy an instance