Run apt-get update automatically under Debian

2009-07-10 20:48:00 by Saz

There are a few different ways to run apt-get update. But there is already a cronjob included in the apt-package. This cronjob is lying in /etc/cron.daily/apt and has almost nothing to do, because everything is disabled by default. You can add the following lines to your apt.conf, to make things work. Start your favorite editor and open /etc/apt/apt.conf (by default, this file does not exists).

  • Run apt-get update everyday:
APT::Periodic::Update-Package-Lists 1;
  • Fetch all upgradeable packages every 7 days:
APT::Periodic::Download-Upgradeable-Packages 7;
  • Run apt-get autoclean every 7 days:
APT::Periodic::AutocleanInterval 7;
  • Run unattended upgrade every n days (0 disables it):
APT::Periodic::Unattended-Upgrade 0;

You can enable unattended upgrades by changing it to a positive value greater zero. But keep in mind, that this can seriously damage your system, if things go wrong! If you like to check, if everything is working as excepted, you may be waiting a few minutes. The cronjob is using a random value for sleeping some time. This is useful, to make sure, that your systems won't connect to your apt-mirror at the same time. But for testing, this is really annoying.

Let's change it for testing. Add the following line to your apt.conf:

APT::Periodic::RandomSleep 5;

If you've finished testing, simply remove this line.


Comments

Fork me on GitHub