The answers here will depend on whether the server owner has worked on servers professionally or not.
People seem to love overcomplicating this subject but it's not hard
APT based distros:
apt-get update
apt-get upgrade -y
reboot
EL distros:
dnf update
reboot
- Use root crontab to schedule, or one of the /etc/cron.[daily|weekly|monthly] dirs. I use a variety of schedules at work - 2nd and 4th Tuesdays of each month. Every day for DMZs. 70 or 80 vms at a time.
Provisos:
- Ensure root email reaches you, so you see any repo or package manager errors from crontab.
- You can wrap this in a bash script. Or use ansible. Add whatever additions you need (notifications, logger lines, shutting stuff down in a particular order - whatever your pets need).
Defences:
- You should have reliable repos already. Remember that dnf can have multiple sources per repo if you want redundancy (We use an internal mirror for speed, but if that does go down, then the vms failover to the internet)
- What about a bad package? It happens, but rare. At scale, ansible with batches and break lines if a certain percentage fail. Use inventory groups to prioritise non-production machines first as canaries)
- Don't trust a repo source against supply-chain attacks? Then never use their software, let alone add its repo. But you will have to trust your distro. No way around that.
- Critical systems? Then you're into the realm of soak-testing and staging. Beyond the scope of this, but even there, the actual patching is very similar, just with staged repos instead of live ones. And anyway, critical stuff should be HA.
Benefits:
- Rebooting often means finding problems faster. Your systems should always be able to reboot by themselves. Any failures need to be resolved or automated through. Anyone who is proud of their high uptimes needs taking outside and leaving by the bins.
- Whilst you can check for needsrestart, what's the point when you can reboot in less than a minute and be certain? Clear those caches and flush those buffers, recover leaking memory and freshen the place up, be 100% certain you're using the latest kernel and every app has the latest library.
We've been doing this for years on hundreds of vms, using Centos Linux, Rocky and Debian distros. Problems caused by reboots are negligible and would have been a problem anyway. Problems caused by bad distro packages are rare - maybe once a year. (I don't recall any on Debian, but have had the odd one on Rocky and CentOs before it)
Build bouncy systems. Don't be scared of rebooting.
Depends on the server. A small vm or lxc in my homelab only reachable from the local network? As needed but at least monthly. Done from an ansible playbook usually in batch.
My cloud vps with several services exposed? Daily auto updates with reboots as needed, also some more checks for some edge cases that broke things in the past (e.g. package update deploys and reloads new SELinux policies but doesn’t require a reboot. Due to the reload of the policies all podman networks fail because their policies are volatile, so podman is instructed to rebuild the network on every auto update that doesn’t require a reboot)
Fully automatic reboot at 3am if needed. Working well for years and upgrades from debian 6 to 13 so far
I only do security updates automatically and reboot manually when necessary because of full drive encryption. Otherwise it would wait for me to enter the passphrase after an automatic reboot.
fully automatic and automated reboots, I don't have the patience to babysit servers anymore, and that was more stressful than rewarding anyway
I don't do unattended. I manually update my server OS, so I know when what changed.
I use a fixed schedule, unless it's security related.
Same.
Same here. I do daily updates, but I want to have a rough idea which packages got updated. If something breaks, it's easier to gauge what to roll back. Also, all of my drives are encrypted and (intentionally) require manual unlocking; hence, automated reboots won't work.
Seems like a lot of work.
I have automatic daily borgbackups and automatic daily updates with pre&post btrfs snapshots, followed by a reboot. If I wake up and my server is down, I can boot into a snapshot via grub and rollback in under a minute (tried and tested).
Or boot into the snapshot and look for evidence what broke.
Worst case I can get a clean drive and restore the borg backup in like 1-2h.
But in practice a Debian/Ubuntu package update will almost never break anything...
Full unattended-upgrades for my Debian homelab servers (due for replacement) because I don't care about downtime and it has never broken anything. Manual updates for my personal NixOS server (that I'm also about to replace) because I never set up automatic updates. Weekly manual updates for a production Ubuntu server (that's hopefully about to get axed) because whoever set it up and was supposed to be maintaining it before was an idiot so updates need to be planned carefully.
Linux
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0