Unattended Updates for Ubuntu 24.04 Server
Automated Bash installer script for configuring unattended updates on Ubuntu 24.04 Server.
Important
This script configures unattended updates with the following defaults:
- Installs and updates all available packages
- Installs security updates automatically
- Creates a crontab entry to run updates every Saturday at 04:00
Optional Features
- Enable removal of unused packages
- Enable automatic reboot if needed
- Enable automatic reboot even if users are logged in
Note
Before running the script, decide whether you want to enable the optional features mentioned above. The lines to review in the code are shown below:
#
# Uncomment the next 2 lines to enable automatic removal of unused packages. This equals apt autoremove.
#
# sed -i '/Unattended-Upgrade::Remove-Unused-Dependencies/ s/^\/\/\s*//' "$config2"
# sed -i 's/Remove-Unused-Dependencies "false"/Remove-Unused-Dependencies "true"/' "$config2"
#
# Uncomment the next 2 lines to enable automatic reboot
#
# sed -i '/Unattended-Upgrade::Automatic-Reboot/ s/^\/\/\s*//' "$config2"
# sed -i 's/Automatic-Reboot "false"/Automatic-Reboot "true"/' "$config2"
#
# Uncomment the line below to enable automatic reboot even if users are logged in
#
# sed -i '/Unattended-Upgrade::Automatic-Reboot-WithUsers/ s/^\/\/\s*//' "$config2"
Preparing
Update your package index before running the installer:
sudo apt update -y
Download the Script
Clone the repository from your Git server:
git clone https://git.x-files.dk/server-general/auto-update-ubuntu.git
Usage
Run the script to configure unattended updates automatically:
cd auto-update-ubuntu
sudo ./auto-update-ubuntu
Post-install
Nothing to do.
More Information
More guides and documentation can be found on wiki.x-files.dk
License
Licensed under the MIT License.
Description
Languages
Shell
100%