How to Set Up Automatic System Updates on a VPS
Configuring automatic system updates on VPS
🔹 Why It’s Important
Automatic updates help to:
- keep your VPS secure with the latest patches;
- reduce risks of exploits due to outdated packages;
- save time by automating regular maintenance.
⚙️ 1. For Ubuntu / Debian
1. Install the automatic update package:sudo apt update && sudo apt install unattended-upgrades -y
2. Enable automatic updates:sudo dpkg-reconfigure --priority=low unattended-upgrades
3. Edit configuration manually if needed:sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
4. Ensure these lines are enabled:"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
5. Optional — enable automatic reboot:sudo nano /etc/apt/apt.conf.d/20auto-upgrades
Example:APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
⚙️ 2. For CentOS / AlmaLinux / Rocky Linux
1. Install the tool:sudo yum install dnf-automatic -y
2. Edit configuration:sudo nano /etc/dnf/automatic.conf
3. Set:apply_updates = yes
4. Enable and start the timer:sudo systemctl enable --now dnf-automatic.timer
5. Check status:systemctl status dnf-automatic.timer
✅ Recommendations
- Check update logs occasionally:
cat /var/log/unattended-upgrades/unattended-upgrades.log
- Don’t power off VPS during updates.
- Consider adding email or Telegram alerts for critical systems.