Keeping unstable machines up to date easily.
Posted by Steve on Tue 16 Nov 2004 at 14:46
Because updating systems is usually a simple matter of running two commands people can be tempted to automate this.
The two commands used are:
apt-get update apt-get upgrade
The first updates your systems package lists, so that apt can determine which packages on your system may be upgraded. The second actually performs the update.
Adding these two commands to a cron job (something that can be scheduled to occur at regular intervals with cron) is a tempting idea.
However it is a dangerous one. As the upgrade happens blindly you might miss out on important notes and questions.
An ideal compromise is to download the package lists and the packages that are available - but not actually install them.
For those users on broadband it makes sense to do this overnight. Every day your machine will download the packages, and when you are ready you simply run:
apt-get upgrade
This will actually do the upgrade live for you, without needing to actually download anything. Any questions that are asked will be done in front of you, and any important notes will be immediately visible.
To do this is a simple matter of placing a script in the directory /etc/cron.daily. The scripts in this directory are run automatically once a day, so it's a perfect location for us.
Create a script /etc/cron.daily/update-apt with the following contents:
#!/bin/sh # # Update APT's local packages, making them ready for # upgrading at a later date. # # Clean packages, and download the latest lists /usr/bin/apt-get clean /usr/bin/apt-get update # Now download the packages, but don't install them. /usr/bin/apt-get --download-only --yes upgrade
Don't forget to make the script executable by running:
chmod 755 /etc/cron.daily/update-apt
Now your system should be ready, and tomorrow you should find that running apt-get upgrade takes only a short amount of time, as all the pending packages have been downloaded already.
This package contains a tool that is run by a cron job
at regular intervals. By default it just updates the package list and
download new packages without installing. You can instruct it to run
anything that you can do with apt-get.
.
It also sends mail (configurable) to the system administrator on
errors.
.
Observe that this tool is a security risk, so you should not set it
to do more than necessary (automatic upgrade of all packages is NOT
recommended).
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
-- Steve.org.uk
[ Parent | Reply to this comment ]
Hope nobody will get really disappointed by this.
[ Parent | Reply to this comment ]
apt-get update && apt-get autoclean && apt-get -dy upgradeSince with "clean", you'll delete any packages you downloaded last night and download them again if you had not run the manual "apt-get upgrade" step. "autoclean" will remove packages no longer listed in the Packages files. --bod
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
And don't even think about having automated upgrades.
[ Parent | Reply to this comment ]
See comments in /etc/cron.daily/apt for more information.
[ Parent | Reply to this comment ]
--
"It's Not Magic, It's Work"
Adam
[ Parent | Reply to this comment ]
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
[ Parent | Reply to this comment ]