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?
First, install
gksu
:The easiest way 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, for example:In it you need to comment out the commented sections of the
Allowed Origins
block.Change:
to:
For software that is not on the Ubuntu repos that you would like to update, you need to add an 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, e.g. for Google Chrome:
Inside you will see something like the following:
The origin is obvious (
Origin: Google, Inc.
) and the archive will be whatever is under the lineSuite
(Suite: stable
).If either
Origin
orSuite
is missing, then they will be the empty string. But note that if both are missing, then probably it will not be possible to use that source with unattended upgrades without including other sources with the same issue.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 example's sake"Google\, Inc.:stable";
.Google Chrome's origin is kinda tricky, because it has a space, an end pointn and a comma in it, but most Release files will be easy to read.
As another example, Node JS source specifies an origin (
Node Source
) but not an archive; so you can match it with"Node Source:";
.Allowed Origins is matched using shell-style wildcards (more specifically, with Python's fnmatch()). If you're careful enough to not include conflicting sources, it's possible to write things like
"Node *:*";
.Do not forget to make a backup of your
50unattended-upgrades
file before editing it. Do that with: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.Automated approach for @Bruno Pereira's answer: (Please consider starring the github repo if you find the answer useful.)
Code Link: https://github.com/abhigenie92/unattended_upgrades_repos
Check repositories to add:
Now edit
/etc/apt/apt.conf.d/50unattended-upgrades
to include them:Check to see if they are included:
Editing
/etc/apt/apt.conf.d/50unattended-upgrades
, add the following:This will allow unattended upgrades for all packages.
There are instructions for forcing a rerun to make cron start the automatic update at the following link. The procedure to stop cron is this
and to restart cron to make the automatic update happen now (or at least within a few miutes) is
How it works
Several things will trigger it to run.
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
)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
.