Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I read here how to enable silent automatic updates for Google Chrome. However, I have other repositories like spotify, docky and others for which I would like to enable silent updates.

I am trying to do this in my Ubuntu 10.04 system. But this question applies to all Ubuntu versions. I have the unattended-upgrades package installed.

How can I do this?

share|improve this question
    
Do you want silent security updates. or ALL updates installed without intervention? Why? –  david6 Dec 14 '11 at 23:11
    
Pretty much all updates including the user repositories as well. –  nik90 Dec 14 '11 at 23:20
add comment

2 Answers

up vote 25 down vote accepted

The easiest of enabling unattended updates for your system is to edit the file 50unattended-upgrades inside /etc/apt/apt.conf.d/ with your favourite text editor. In it you need to comment out the commented sections of the Allowed Origins block, ie

sudo gedit /etc/apt/apt.conf.d/50unattended-upgrades

Change

Unattended-Upgrade::Allowed-Origins {
        "${distro_id} ${distro_codename}-security";
//      "${distro_id} ${distro_codename}-updates";
//      "${distro_id} ${distro_codename}-proposed";
//      "${distro_id} ${distro_codename}-backports";
};

to

Unattended-Upgrade::Allowed-Origins {
        "${distro_id} ${distro_codename}-security";
        "${distro_id} ${distro_codename}-updates";
//      "${distro_id} ${distro_codename}-proposed";
//      "${distro_id} ${distro_codename}-backports";
};

For software that is not on the Ubuntu repos that you would like to update you need to add a origin and archive to the file. To find what those are for your PPAs open the folder /var/lib/apt/lists/, that is the storage area for state information for each package resource. What you are looking for is the files that end with Release in the name.

Open one with your text editor, ie for Google Chrome:

gedit /var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_Release

Origin: Google, Inc.
Label: Google
Suite: stable
Codename: stable
Version: 1.0
Date: Thu, 17 Nov 2011 19:09:01 +0000
Architectures: i386 amd64
Components: main
Description: Google chrome-linux repository.

The origin is obvious (Origin: Google, Inc.) and the archive will be whatever is under the line Suite (Suite: stable).

If the Release files does not contain those lines then probably it will not be possible to use that source with unattended upgrades.

After you noted those 2 lines you need to edit the 50unattended-upgrades file and add the lines using this format "<origin>:<archive>"; of for this examples sake "Google\, Inc.:stable";.

Google Chrome's origin is kinda tricky because it has a space a end point and a comma in it but most Release files will be easy to read.


Do not forget to make a backup of your 50unattended-upgrades file before editing it, do that with sudo cp /etc/apt/apt.conf.d/50unattended-upgrades /etc/apt/apt.conf.d/50unattended-upgrades.bak.

To test the changes done on the file you can use sudo unattended-upgrades with the parameters --dry-run and --debug.

--dry-run will run an unattended upgrades cycle except it will not really install the upgrades, only check and verify that everything is ok.

--debug will enable verbose mode.

You can always check the logs for unattended-upgrades at /var/log/unattended-upgrades/unattended-upgrades.log.


You can change the configuration of the unattended upgrades by editing the file /etc/apt/apt.conf.d/10periodic, options for the configuration are in the /etc/cron.daily/apt script header. Read them to configure the frequency of the unattended upgrades.

share|improve this answer
2  
Thanks...Very detailed! may i ask why you put a \ after Google? –  nik90 Dec 14 '11 at 23:20
    
Because of the special characters in the origin, its an escape character for the comma. Most origins you find will not have that. –  Bruno Pereira Dec 14 '11 at 23:25
    
Added more information on how to test and configure. –  Bruno Pereira Dec 14 '11 at 23:26
    
libreoffice's PPA has Origin: LP-PPA-libreoffice and suite: lucid. Does that mean I need to do "LP\-PPA\-libreoffice:lucid" ? –  nik90 Dec 14 '11 at 23:35
1  
@jos No, that is the way it works, --dry-run will check if on the updated lists there is any updates available and output them to you, the lists updates via whatever is your configuration in /etc/cron.daily/apt, running it manually does not update the lists I think. –  Bruno Pereira Aug 11 '12 at 10:10
show 10 more comments

There are instructions for forcing a rerun to make cron start the automatic update at the following link. http://www.richud.com/wiki/Ubuntu_Enable_Automatic_Updates#Forcing_a_rerun_to_test_cron_working

The procedure to stop cron is this

sudo service anacron stop
sudo service cron stop
sudo rm -rf /var/run/unattend* /var/run/cron* /var/run/anacron*
sudo rm -rf /var/lib/apt/periodic/*

and to restart cron to make the automatic update happen now (or at least within a few miutes) is

sudo service cron start
sudo anacron -fn

How it works

Several things will trigger it to run. a) It is fired off from the running of /etc/cron.daily by cron, specifically /etc/cron.daily/apt. Cron runs /etc/cron.daily at 6.25 am (see /etc/crontab) b) Anacron runs from upstart? and it will fire off /etc/cron.daily after 5 minutes of uptime (see /etc/anacrontab)

  • Note APT::Periodic::RandomSleep can be set in /etc/apt/apt.conf.d/10periodic, but defaults to 1800s (30 mins) so no updates may happen till 30 mins after /etc/cron.daily/apt runs.

Log

If it works things should get logged in this folder, /var/log/unattended-upgrades

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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