How can I set my Ubuntu to not only update regularly (and automagically) the security updates (I could set that when installing ubuntu), but to update ALL the packages automatically, in the background, without user interaction?

Extra question: if I could configure that how often does my Ubuntu box check for update, then what should I set? Check it in every hour? Or are there any built-in random way, I mean Ubuntu waits for a random time, then it checks for updates? (to not give big traffic to the repository servers at every whole hour, e.g.: 20h; 21h; 22h; etc.)


Install the unattended-upgrades package, and edit its config file to install all packages, not just security updates:

Edit the file /etc/apt/apt.conf.d/50unattended-upgrades:

// Automatically upgrade packages from these (origin, archive) pairs
Unattended-Upgrade::Allowed-Origins {
        "${distro_id} ${distro_codename}-security";
//      "${distro_id} ${distro_codename}-updates";
//      "${distro_id} ${distro_codename}-proposed";
//      "${distro_id} ${distro_codename}-backports";

and remove the // from the parts you want to be automatic and then just save the file.

Next you need to set the autoupdate functions in /etc/apt/apt.conf.d/10periodic:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

The update interval is every day, which is about right, otherwise you'd probably be hitting the mirror too often.

Here's the documentation for this:

  • 1
    Can I ask that what does "1 day" mean exactly? If e.g.: a pc is only used 1-2 hours a day, then it will not check for updates? OR it means e.g.: if 24 hours passed after the last check it performs an update? Jun 10 '11 at 0:42

Automatic Daily Package Updates Using Cron And Apt-Get

WARNING: As with any system changes, the potential for creating new or additional problems may occur. Please be sure to backup your data and configurations! Use this document at your own risk.

Creating the Daily Cron Job File

First you will need to create the cron job file. You can use a simple text editor to create the file and save it in your home directory. In the Text Editor, type the following lines:

apt-get update
apt-get upgrade -y
apt-get autoclean

Now click Save and name the file something like "autoupdt".

Moving the Cron Job File to Cron.Daily

Now that you have created the cron job file, it needs to be moved into the daily cron directory so that it will be run automatically on a daily basis. To do this, we first need to open a command line terminal (CTRL+ALT+T).

We need to move the file to the proper directory. Type the following command at the command line prompt to move the file:

sudo mv /where/ever/autoupdt /etc/cron.daily

Making the Cron Job File Executable

Now that the file is created and ready to be run daily by cron, we still need to make the file executable in order for cron to be able to run it.

sudo chmod 755 /etc/cron.daily/autoupdt


For more details on custom configuration of cron, please refer to:

man cron


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.