Enable automatic updates from command line
I'm creating a BASH script that will, among other things, enable automatic updates, important security updates, and the "Check daily" option in the software updates menu. But no matter where i search, i cant find an answer. From what i can tell, the only way to do it is through the GUI. Is there anyway to do this that im missing?
EDIT 1:
Through some more research, I have figured out how to enable important securty updates and reccomended updates with this bit of code:
find /etc/apt -type f -name '*.list' -exec sed -i 's/^#(deb.*-backports.*)/1/; s/^#(deb.*-updates.*)/1/; s/^#(deb.*-proposed.*)/1/; s/^#(deb.*-security.*)/1/' {} +
From How to enable or disable -updates, -security, -backports, -proposed repositories from commandline?
bash scripts update-manager
add a comment |
I'm creating a BASH script that will, among other things, enable automatic updates, important security updates, and the "Check daily" option in the software updates menu. But no matter where i search, i cant find an answer. From what i can tell, the only way to do it is through the GUI. Is there anyway to do this that im missing?
EDIT 1:
Through some more research, I have figured out how to enable important securty updates and reccomended updates with this bit of code:
find /etc/apt -type f -name '*.list' -exec sed -i 's/^#(deb.*-backports.*)/1/; s/^#(deb.*-updates.*)/1/; s/^#(deb.*-proposed.*)/1/; s/^#(deb.*-security.*)/1/' {} +
From How to enable or disable -updates, -security, -backports, -proposed repositories from commandline?
bash scripts update-manager
So to clarify, you're still looking for how to enable automatic updates and enable the "Check daily" option, right? What version of Ubuntu are you asking about?
– wjandrea
Jan 11 at 3:22
Instead of sed-ing files, you can simply place your own config file in /etc/apt/apt.conf.d. Give it a high number like "99-my-config-changes" so it takes precedence over earlier-loaded config settings. Custom configs are rarely neccessary - unattended-upgrades has sane default settings.
– user535733
Jan 11 at 3:30
I am currently using ubuntu 18.04.1 LTS, and yes i am still looking for the Check daily option
– Tech_Person
Jan 11 at 3:33
Editing sources.list files isn't directly related to updating automatically... the sources choose where to update from, but not when. And which program do you want to use/edit, unattended-upgrades, gnome update manager, cron & aptitude, cron-apt?
– Xen2050
Jan 11 at 4:43
@Xen2050 I want to edit whatever file the GUI uses when you change it manually, i want the exact same result.
– Tech_Person
Jan 12 at 5:36
add a comment |
I'm creating a BASH script that will, among other things, enable automatic updates, important security updates, and the "Check daily" option in the software updates menu. But no matter where i search, i cant find an answer. From what i can tell, the only way to do it is through the GUI. Is there anyway to do this that im missing?
EDIT 1:
Through some more research, I have figured out how to enable important securty updates and reccomended updates with this bit of code:
find /etc/apt -type f -name '*.list' -exec sed -i 's/^#(deb.*-backports.*)/1/; s/^#(deb.*-updates.*)/1/; s/^#(deb.*-proposed.*)/1/; s/^#(deb.*-security.*)/1/' {} +
From How to enable or disable -updates, -security, -backports, -proposed repositories from commandline?
bash scripts update-manager
I'm creating a BASH script that will, among other things, enable automatic updates, important security updates, and the "Check daily" option in the software updates menu. But no matter where i search, i cant find an answer. From what i can tell, the only way to do it is through the GUI. Is there anyway to do this that im missing?
EDIT 1:
Through some more research, I have figured out how to enable important securty updates and reccomended updates with this bit of code:
find /etc/apt -type f -name '*.list' -exec sed -i 's/^#(deb.*-backports.*)/1/; s/^#(deb.*-updates.*)/1/; s/^#(deb.*-proposed.*)/1/; s/^#(deb.*-security.*)/1/' {} +
From How to enable or disable -updates, -security, -backports, -proposed repositories from commandline?
bash scripts update-manager
bash scripts update-manager
edited Jan 11 at 3:21
wjandrea
8,63442260
8,63442260
asked Jan 11 at 2:41
Tech_PersonTech_Person
298
298
So to clarify, you're still looking for how to enable automatic updates and enable the "Check daily" option, right? What version of Ubuntu are you asking about?
– wjandrea
Jan 11 at 3:22
Instead of sed-ing files, you can simply place your own config file in /etc/apt/apt.conf.d. Give it a high number like "99-my-config-changes" so it takes precedence over earlier-loaded config settings. Custom configs are rarely neccessary - unattended-upgrades has sane default settings.
– user535733
Jan 11 at 3:30
I am currently using ubuntu 18.04.1 LTS, and yes i am still looking for the Check daily option
– Tech_Person
Jan 11 at 3:33
Editing sources.list files isn't directly related to updating automatically... the sources choose where to update from, but not when. And which program do you want to use/edit, unattended-upgrades, gnome update manager, cron & aptitude, cron-apt?
– Xen2050
Jan 11 at 4:43
@Xen2050 I want to edit whatever file the GUI uses when you change it manually, i want the exact same result.
– Tech_Person
Jan 12 at 5:36
add a comment |
So to clarify, you're still looking for how to enable automatic updates and enable the "Check daily" option, right? What version of Ubuntu are you asking about?
– wjandrea
Jan 11 at 3:22
Instead of sed-ing files, you can simply place your own config file in /etc/apt/apt.conf.d. Give it a high number like "99-my-config-changes" so it takes precedence over earlier-loaded config settings. Custom configs are rarely neccessary - unattended-upgrades has sane default settings.
– user535733
Jan 11 at 3:30
I am currently using ubuntu 18.04.1 LTS, and yes i am still looking for the Check daily option
– Tech_Person
Jan 11 at 3:33
Editing sources.list files isn't directly related to updating automatically... the sources choose where to update from, but not when. And which program do you want to use/edit, unattended-upgrades, gnome update manager, cron & aptitude, cron-apt?
– Xen2050
Jan 11 at 4:43
@Xen2050 I want to edit whatever file the GUI uses when you change it manually, i want the exact same result.
– Tech_Person
Jan 12 at 5:36
So to clarify, you're still looking for how to enable automatic updates and enable the "Check daily" option, right? What version of Ubuntu are you asking about?
– wjandrea
Jan 11 at 3:22
So to clarify, you're still looking for how to enable automatic updates and enable the "Check daily" option, right? What version of Ubuntu are you asking about?
– wjandrea
Jan 11 at 3:22
Instead of sed-ing files, you can simply place your own config file in /etc/apt/apt.conf.d. Give it a high number like "99-my-config-changes" so it takes precedence over earlier-loaded config settings. Custom configs are rarely neccessary - unattended-upgrades has sane default settings.
– user535733
Jan 11 at 3:30
Instead of sed-ing files, you can simply place your own config file in /etc/apt/apt.conf.d. Give it a high number like "99-my-config-changes" so it takes precedence over earlier-loaded config settings. Custom configs are rarely neccessary - unattended-upgrades has sane default settings.
– user535733
Jan 11 at 3:30
I am currently using ubuntu 18.04.1 LTS, and yes i am still looking for the Check daily option
– Tech_Person
Jan 11 at 3:33
I am currently using ubuntu 18.04.1 LTS, and yes i am still looking for the Check daily option
– Tech_Person
Jan 11 at 3:33
Editing sources.list files isn't directly related to updating automatically... the sources choose where to update from, but not when. And which program do you want to use/edit, unattended-upgrades, gnome update manager, cron & aptitude, cron-apt?
– Xen2050
Jan 11 at 4:43
Editing sources.list files isn't directly related to updating automatically... the sources choose where to update from, but not when. And which program do you want to use/edit, unattended-upgrades, gnome update manager, cron & aptitude, cron-apt?
– Xen2050
Jan 11 at 4:43
@Xen2050 I want to edit whatever file the GUI uses when you change it manually, i want the exact same result.
– Tech_Person
Jan 12 at 5:36
@Xen2050 I want to edit whatever file the GUI uses when you change it manually, i want the exact same result.
– Tech_Person
Jan 12 at 5:36
add a comment |
2 Answers
2
active
oldest
votes
If you're using the unattended-upgrades
package and it's already installed, then according to Ubuntu's Community Help Wiki on AutomaticSecurityUpdates (FYI it also has info on using GNOME Update Manager, cron and aptitude, and cron-apt):
Determining the current configuration
The current configuration can be queried by running:
apt-config dump APT::Periodic::Unattended-Upgrade
Which will produce output like:
APT::Periodic::Unattended-Upgrade "1";
In this example, Unattended Upgrade will run every 1 day. If the number is "0" then unattended upgrades are disabled.
The files in /etc/apt/apt.conf.d/ are evaluated in lexicographical order with each file capable of overriding values set in earlier files. This makes it insufficient to view the setting in /etc/apt/apt.conf.d/20auto-upgrades and why it is recommended to use apt-config.
To enable it, do:
sudo dpkg-reconfigure --priority=low unattended-upgrades
(it's an interactive dialog) which will create
/etc/apt/apt.conf.d/50unattended-upgrades
. And/etc/apt/apt.conf.d/20auto-upgrades
with the following contents:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
Details about what these values mean may be found in the header of the /etc/cron.daily/apt file.
If you're absolutely sure you wouldn't miss out on anything else dpkg-reconfigure
does (I'm not sure the above is an exhaustive list), you could just create/edit the above files.
Or instead of the above, according to the Debian wiki on UnattendedUpgrades:
Automatic call via /etc/apt/apt.conf.d/02periodic
Alternatively, you can also create the apt configuration file
/etc/apt/apt.conf.d/02periodic
to activate unattended-upgrades:
Below is an example /etc/apt/apt.conf.d/02periodic:
// Control parameters for cron jobs by /etc/cron.daily/apt-compat //
// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";
// Do "apt-get update" automatically every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";
// Do "apt-get upgrade --download-only" every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";
// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";
// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";
// Send report mail to root
// 0: no report (or null string)
// 1: progress report (actually any string)
// 2: + command outputs (remove -qq, remove 2>/dev/null, add -d)
// 3: + trace on
APT::Periodic::Verbose "2";
Manual run (for debugging)
To aid debugging you may need to run unattended-upgrades manually thus:
sudo unattended-upgrade -d
See Also
- /usr/share/doc/unattended-upgrades/README.md.gz
- /usr/share/doc/apt/examples/configure-index.gz
- /etc/cron.daily/apt
- apt.conf(5)
Also, some more info you might be interested in:
Related systemd files
Because Debian is using the systemd system, it has timers defined for APT use, these files are provided by the apt package.
The relevant files are:
- Used for downloads:
/lib/systemd/system/apt-daily.timer
- override with
/etc/systemd/system/apt-daily.timer.d/override.conf
- Used for upgrading:
/lib/systemd/system/apt-daily-upgrade.timer
- override with
/etc/systemd/system/apt-daily-upgrade.d/override.conf
You can override these settings using local override files as shown above, creating the missing parts if non-existent yet.
Here is an example of how to override the download time to 1AM using
/etc/systemd/system/apt-daily.timer.d/override.conf
:
[Timer]
OnCalendar=
OnCalendar=01:00
Line #2 above is needed to reset (empty) the default value shown below in line #5.
The default in
/lib/systemd/system/apt-daily.timer
is (at moment of this writing):
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=*-*-* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
add a comment |
Unattended upgrades are enabled by default in all Ubuntu releases 16.04 and newer.
There are three easy ways to tell if the unattended-upgrades
package is installed and working.
1) See if the package is installed. Look for "[installed]" at the end of the bottom line of output.
$ apt list unattended-upgrades
Listing... Done
unattended-upgrades/cosmic-updates,cosmic-updates,now 1.5ubuntu3.18.10.1 all [installed]
2) Check the apt timestamps for unattended-upgrades activity. Look for a timestamp by unattended-upgrades within the past day or two:
$ ls -la /var/lib/apt/periodic/
total 8
drwxr-xr-x 2 root root 4096 Sep 15 2017 .
drwxr-xr-x 5 root root 4096 Jan 1 08:24 ..
-rw-r--r-- 1 root root 0 Jan 10 07:54 download-upgradeable-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:51 unattended-upgrades-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:52 update-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:53 update-success-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:55 upgrade-stamp
3) Check the apt settings to see if Unattended Upgrades is turned on ("1") or off ("0"):
$ grep Unattended-Upgrade /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Unattended-Upgrade "1";
The repositories that unattended-upgrades uses are listed in /etc/apt/apt.conf.d/50unattended-upgrade.
- The -security repository is enabled by default in all releases of Ubuntu.
- Adding other Ubuntu repositories is trivial: Simply uncomment the appropriate line.
- Enabling -backports is discouraged, those packages are not fully tested.
- Enabling -proposed is STRONGLY DISCOURAGED, as those packages can be very risky.
If unattended-upgrades is installed and turned on, it will run daily whether you want it to or not. Only the GUI provides the option to change the period.
After you make changes you do not need to restart your system. Apt runs once daily at a random time, and reloads it's configs and sources anew each time.
most of this doesnt really help me, i checked to confirm that "Unattenended-upgrades" is installed and working, but i want this script to set automatic updates to daily, regardless of what machine i run it on. The machines that this script will be run on will most likely have it set to "Never"
– Tech_Person
Jan 11 at 3:43
It's long because you were heading down a more difficult road than you need to.
– user535733
Jan 11 at 4:19
so, i didnt really get a clear answer though. How exactly do i enable automatic checking for updates daily?
– Tech_Person
Jan 11 at 4:26
u-u ignores the GUI setting, and runs daily when enabled. The GUI control is older; from before the days when u-u was enabled by default. If you want standardization, there are several easy ways.
– user535733
Jan 11 at 13:36
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1108738%2fenable-automatic-updates-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you're using the unattended-upgrades
package and it's already installed, then according to Ubuntu's Community Help Wiki on AutomaticSecurityUpdates (FYI it also has info on using GNOME Update Manager, cron and aptitude, and cron-apt):
Determining the current configuration
The current configuration can be queried by running:
apt-config dump APT::Periodic::Unattended-Upgrade
Which will produce output like:
APT::Periodic::Unattended-Upgrade "1";
In this example, Unattended Upgrade will run every 1 day. If the number is "0" then unattended upgrades are disabled.
The files in /etc/apt/apt.conf.d/ are evaluated in lexicographical order with each file capable of overriding values set in earlier files. This makes it insufficient to view the setting in /etc/apt/apt.conf.d/20auto-upgrades and why it is recommended to use apt-config.
To enable it, do:
sudo dpkg-reconfigure --priority=low unattended-upgrades
(it's an interactive dialog) which will create
/etc/apt/apt.conf.d/50unattended-upgrades
. And/etc/apt/apt.conf.d/20auto-upgrades
with the following contents:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
Details about what these values mean may be found in the header of the /etc/cron.daily/apt file.
If you're absolutely sure you wouldn't miss out on anything else dpkg-reconfigure
does (I'm not sure the above is an exhaustive list), you could just create/edit the above files.
Or instead of the above, according to the Debian wiki on UnattendedUpgrades:
Automatic call via /etc/apt/apt.conf.d/02periodic
Alternatively, you can also create the apt configuration file
/etc/apt/apt.conf.d/02periodic
to activate unattended-upgrades:
Below is an example /etc/apt/apt.conf.d/02periodic:
// Control parameters for cron jobs by /etc/cron.daily/apt-compat //
// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";
// Do "apt-get update" automatically every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";
// Do "apt-get upgrade --download-only" every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";
// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";
// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";
// Send report mail to root
// 0: no report (or null string)
// 1: progress report (actually any string)
// 2: + command outputs (remove -qq, remove 2>/dev/null, add -d)
// 3: + trace on
APT::Periodic::Verbose "2";
Manual run (for debugging)
To aid debugging you may need to run unattended-upgrades manually thus:
sudo unattended-upgrade -d
See Also
- /usr/share/doc/unattended-upgrades/README.md.gz
- /usr/share/doc/apt/examples/configure-index.gz
- /etc/cron.daily/apt
- apt.conf(5)
Also, some more info you might be interested in:
Related systemd files
Because Debian is using the systemd system, it has timers defined for APT use, these files are provided by the apt package.
The relevant files are:
- Used for downloads:
/lib/systemd/system/apt-daily.timer
- override with
/etc/systemd/system/apt-daily.timer.d/override.conf
- Used for upgrading:
/lib/systemd/system/apt-daily-upgrade.timer
- override with
/etc/systemd/system/apt-daily-upgrade.d/override.conf
You can override these settings using local override files as shown above, creating the missing parts if non-existent yet.
Here is an example of how to override the download time to 1AM using
/etc/systemd/system/apt-daily.timer.d/override.conf
:
[Timer]
OnCalendar=
OnCalendar=01:00
Line #2 above is needed to reset (empty) the default value shown below in line #5.
The default in
/lib/systemd/system/apt-daily.timer
is (at moment of this writing):
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=*-*-* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
add a comment |
If you're using the unattended-upgrades
package and it's already installed, then according to Ubuntu's Community Help Wiki on AutomaticSecurityUpdates (FYI it also has info on using GNOME Update Manager, cron and aptitude, and cron-apt):
Determining the current configuration
The current configuration can be queried by running:
apt-config dump APT::Periodic::Unattended-Upgrade
Which will produce output like:
APT::Periodic::Unattended-Upgrade "1";
In this example, Unattended Upgrade will run every 1 day. If the number is "0" then unattended upgrades are disabled.
The files in /etc/apt/apt.conf.d/ are evaluated in lexicographical order with each file capable of overriding values set in earlier files. This makes it insufficient to view the setting in /etc/apt/apt.conf.d/20auto-upgrades and why it is recommended to use apt-config.
To enable it, do:
sudo dpkg-reconfigure --priority=low unattended-upgrades
(it's an interactive dialog) which will create
/etc/apt/apt.conf.d/50unattended-upgrades
. And/etc/apt/apt.conf.d/20auto-upgrades
with the following contents:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
Details about what these values mean may be found in the header of the /etc/cron.daily/apt file.
If you're absolutely sure you wouldn't miss out on anything else dpkg-reconfigure
does (I'm not sure the above is an exhaustive list), you could just create/edit the above files.
Or instead of the above, according to the Debian wiki on UnattendedUpgrades:
Automatic call via /etc/apt/apt.conf.d/02periodic
Alternatively, you can also create the apt configuration file
/etc/apt/apt.conf.d/02periodic
to activate unattended-upgrades:
Below is an example /etc/apt/apt.conf.d/02periodic:
// Control parameters for cron jobs by /etc/cron.daily/apt-compat //
// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";
// Do "apt-get update" automatically every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";
// Do "apt-get upgrade --download-only" every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";
// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";
// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";
// Send report mail to root
// 0: no report (or null string)
// 1: progress report (actually any string)
// 2: + command outputs (remove -qq, remove 2>/dev/null, add -d)
// 3: + trace on
APT::Periodic::Verbose "2";
Manual run (for debugging)
To aid debugging you may need to run unattended-upgrades manually thus:
sudo unattended-upgrade -d
See Also
- /usr/share/doc/unattended-upgrades/README.md.gz
- /usr/share/doc/apt/examples/configure-index.gz
- /etc/cron.daily/apt
- apt.conf(5)
Also, some more info you might be interested in:
Related systemd files
Because Debian is using the systemd system, it has timers defined for APT use, these files are provided by the apt package.
The relevant files are:
- Used for downloads:
/lib/systemd/system/apt-daily.timer
- override with
/etc/systemd/system/apt-daily.timer.d/override.conf
- Used for upgrading:
/lib/systemd/system/apt-daily-upgrade.timer
- override with
/etc/systemd/system/apt-daily-upgrade.d/override.conf
You can override these settings using local override files as shown above, creating the missing parts if non-existent yet.
Here is an example of how to override the download time to 1AM using
/etc/systemd/system/apt-daily.timer.d/override.conf
:
[Timer]
OnCalendar=
OnCalendar=01:00
Line #2 above is needed to reset (empty) the default value shown below in line #5.
The default in
/lib/systemd/system/apt-daily.timer
is (at moment of this writing):
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=*-*-* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
add a comment |
If you're using the unattended-upgrades
package and it's already installed, then according to Ubuntu's Community Help Wiki on AutomaticSecurityUpdates (FYI it also has info on using GNOME Update Manager, cron and aptitude, and cron-apt):
Determining the current configuration
The current configuration can be queried by running:
apt-config dump APT::Periodic::Unattended-Upgrade
Which will produce output like:
APT::Periodic::Unattended-Upgrade "1";
In this example, Unattended Upgrade will run every 1 day. If the number is "0" then unattended upgrades are disabled.
The files in /etc/apt/apt.conf.d/ are evaluated in lexicographical order with each file capable of overriding values set in earlier files. This makes it insufficient to view the setting in /etc/apt/apt.conf.d/20auto-upgrades and why it is recommended to use apt-config.
To enable it, do:
sudo dpkg-reconfigure --priority=low unattended-upgrades
(it's an interactive dialog) which will create
/etc/apt/apt.conf.d/50unattended-upgrades
. And/etc/apt/apt.conf.d/20auto-upgrades
with the following contents:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
Details about what these values mean may be found in the header of the /etc/cron.daily/apt file.
If you're absolutely sure you wouldn't miss out on anything else dpkg-reconfigure
does (I'm not sure the above is an exhaustive list), you could just create/edit the above files.
Or instead of the above, according to the Debian wiki on UnattendedUpgrades:
Automatic call via /etc/apt/apt.conf.d/02periodic
Alternatively, you can also create the apt configuration file
/etc/apt/apt.conf.d/02periodic
to activate unattended-upgrades:
Below is an example /etc/apt/apt.conf.d/02periodic:
// Control parameters for cron jobs by /etc/cron.daily/apt-compat //
// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";
// Do "apt-get update" automatically every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";
// Do "apt-get upgrade --download-only" every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";
// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";
// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";
// Send report mail to root
// 0: no report (or null string)
// 1: progress report (actually any string)
// 2: + command outputs (remove -qq, remove 2>/dev/null, add -d)
// 3: + trace on
APT::Periodic::Verbose "2";
Manual run (for debugging)
To aid debugging you may need to run unattended-upgrades manually thus:
sudo unattended-upgrade -d
See Also
- /usr/share/doc/unattended-upgrades/README.md.gz
- /usr/share/doc/apt/examples/configure-index.gz
- /etc/cron.daily/apt
- apt.conf(5)
Also, some more info you might be interested in:
Related systemd files
Because Debian is using the systemd system, it has timers defined for APT use, these files are provided by the apt package.
The relevant files are:
- Used for downloads:
/lib/systemd/system/apt-daily.timer
- override with
/etc/systemd/system/apt-daily.timer.d/override.conf
- Used for upgrading:
/lib/systemd/system/apt-daily-upgrade.timer
- override with
/etc/systemd/system/apt-daily-upgrade.d/override.conf
You can override these settings using local override files as shown above, creating the missing parts if non-existent yet.
Here is an example of how to override the download time to 1AM using
/etc/systemd/system/apt-daily.timer.d/override.conf
:
[Timer]
OnCalendar=
OnCalendar=01:00
Line #2 above is needed to reset (empty) the default value shown below in line #5.
The default in
/lib/systemd/system/apt-daily.timer
is (at moment of this writing):
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=*-*-* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
If you're using the unattended-upgrades
package and it's already installed, then according to Ubuntu's Community Help Wiki on AutomaticSecurityUpdates (FYI it also has info on using GNOME Update Manager, cron and aptitude, and cron-apt):
Determining the current configuration
The current configuration can be queried by running:
apt-config dump APT::Periodic::Unattended-Upgrade
Which will produce output like:
APT::Periodic::Unattended-Upgrade "1";
In this example, Unattended Upgrade will run every 1 day. If the number is "0" then unattended upgrades are disabled.
The files in /etc/apt/apt.conf.d/ are evaluated in lexicographical order with each file capable of overriding values set in earlier files. This makes it insufficient to view the setting in /etc/apt/apt.conf.d/20auto-upgrades and why it is recommended to use apt-config.
To enable it, do:
sudo dpkg-reconfigure --priority=low unattended-upgrades
(it's an interactive dialog) which will create
/etc/apt/apt.conf.d/50unattended-upgrades
. And/etc/apt/apt.conf.d/20auto-upgrades
with the following contents:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
Details about what these values mean may be found in the header of the /etc/cron.daily/apt file.
If you're absolutely sure you wouldn't miss out on anything else dpkg-reconfigure
does (I'm not sure the above is an exhaustive list), you could just create/edit the above files.
Or instead of the above, according to the Debian wiki on UnattendedUpgrades:
Automatic call via /etc/apt/apt.conf.d/02periodic
Alternatively, you can also create the apt configuration file
/etc/apt/apt.conf.d/02periodic
to activate unattended-upgrades:
Below is an example /etc/apt/apt.conf.d/02periodic:
// Control parameters for cron jobs by /etc/cron.daily/apt-compat //
// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";
// Do "apt-get update" automatically every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";
// Do "apt-get upgrade --download-only" every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";
// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";
// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";
// Send report mail to root
// 0: no report (or null string)
// 1: progress report (actually any string)
// 2: + command outputs (remove -qq, remove 2>/dev/null, add -d)
// 3: + trace on
APT::Periodic::Verbose "2";
Manual run (for debugging)
To aid debugging you may need to run unattended-upgrades manually thus:
sudo unattended-upgrade -d
See Also
- /usr/share/doc/unattended-upgrades/README.md.gz
- /usr/share/doc/apt/examples/configure-index.gz
- /etc/cron.daily/apt
- apt.conf(5)
Also, some more info you might be interested in:
Related systemd files
Because Debian is using the systemd system, it has timers defined for APT use, these files are provided by the apt package.
The relevant files are:
- Used for downloads:
/lib/systemd/system/apt-daily.timer
- override with
/etc/systemd/system/apt-daily.timer.d/override.conf
- Used for upgrading:
/lib/systemd/system/apt-daily-upgrade.timer
- override with
/etc/systemd/system/apt-daily-upgrade.d/override.conf
You can override these settings using local override files as shown above, creating the missing parts if non-existent yet.
Here is an example of how to override the download time to 1AM using
/etc/systemd/system/apt-daily.timer.d/override.conf
:
[Timer]
OnCalendar=
OnCalendar=01:00
Line #2 above is needed to reset (empty) the default value shown below in line #5.
The default in
/lib/systemd/system/apt-daily.timer
is (at moment of this writing):
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=*-*-* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
answered Jan 11 at 5:28
Xen2050Xen2050
6,75712243
6,75712243
add a comment |
add a comment |
Unattended upgrades are enabled by default in all Ubuntu releases 16.04 and newer.
There are three easy ways to tell if the unattended-upgrades
package is installed and working.
1) See if the package is installed. Look for "[installed]" at the end of the bottom line of output.
$ apt list unattended-upgrades
Listing... Done
unattended-upgrades/cosmic-updates,cosmic-updates,now 1.5ubuntu3.18.10.1 all [installed]
2) Check the apt timestamps for unattended-upgrades activity. Look for a timestamp by unattended-upgrades within the past day or two:
$ ls -la /var/lib/apt/periodic/
total 8
drwxr-xr-x 2 root root 4096 Sep 15 2017 .
drwxr-xr-x 5 root root 4096 Jan 1 08:24 ..
-rw-r--r-- 1 root root 0 Jan 10 07:54 download-upgradeable-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:51 unattended-upgrades-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:52 update-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:53 update-success-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:55 upgrade-stamp
3) Check the apt settings to see if Unattended Upgrades is turned on ("1") or off ("0"):
$ grep Unattended-Upgrade /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Unattended-Upgrade "1";
The repositories that unattended-upgrades uses are listed in /etc/apt/apt.conf.d/50unattended-upgrade.
- The -security repository is enabled by default in all releases of Ubuntu.
- Adding other Ubuntu repositories is trivial: Simply uncomment the appropriate line.
- Enabling -backports is discouraged, those packages are not fully tested.
- Enabling -proposed is STRONGLY DISCOURAGED, as those packages can be very risky.
If unattended-upgrades is installed and turned on, it will run daily whether you want it to or not. Only the GUI provides the option to change the period.
After you make changes you do not need to restart your system. Apt runs once daily at a random time, and reloads it's configs and sources anew each time.
most of this doesnt really help me, i checked to confirm that "Unattenended-upgrades" is installed and working, but i want this script to set automatic updates to daily, regardless of what machine i run it on. The machines that this script will be run on will most likely have it set to "Never"
– Tech_Person
Jan 11 at 3:43
It's long because you were heading down a more difficult road than you need to.
– user535733
Jan 11 at 4:19
so, i didnt really get a clear answer though. How exactly do i enable automatic checking for updates daily?
– Tech_Person
Jan 11 at 4:26
u-u ignores the GUI setting, and runs daily when enabled. The GUI control is older; from before the days when u-u was enabled by default. If you want standardization, there are several easy ways.
– user535733
Jan 11 at 13:36
add a comment |
Unattended upgrades are enabled by default in all Ubuntu releases 16.04 and newer.
There are three easy ways to tell if the unattended-upgrades
package is installed and working.
1) See if the package is installed. Look for "[installed]" at the end of the bottom line of output.
$ apt list unattended-upgrades
Listing... Done
unattended-upgrades/cosmic-updates,cosmic-updates,now 1.5ubuntu3.18.10.1 all [installed]
2) Check the apt timestamps for unattended-upgrades activity. Look for a timestamp by unattended-upgrades within the past day or two:
$ ls -la /var/lib/apt/periodic/
total 8
drwxr-xr-x 2 root root 4096 Sep 15 2017 .
drwxr-xr-x 5 root root 4096 Jan 1 08:24 ..
-rw-r--r-- 1 root root 0 Jan 10 07:54 download-upgradeable-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:51 unattended-upgrades-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:52 update-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:53 update-success-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:55 upgrade-stamp
3) Check the apt settings to see if Unattended Upgrades is turned on ("1") or off ("0"):
$ grep Unattended-Upgrade /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Unattended-Upgrade "1";
The repositories that unattended-upgrades uses are listed in /etc/apt/apt.conf.d/50unattended-upgrade.
- The -security repository is enabled by default in all releases of Ubuntu.
- Adding other Ubuntu repositories is trivial: Simply uncomment the appropriate line.
- Enabling -backports is discouraged, those packages are not fully tested.
- Enabling -proposed is STRONGLY DISCOURAGED, as those packages can be very risky.
If unattended-upgrades is installed and turned on, it will run daily whether you want it to or not. Only the GUI provides the option to change the period.
After you make changes you do not need to restart your system. Apt runs once daily at a random time, and reloads it's configs and sources anew each time.
most of this doesnt really help me, i checked to confirm that "Unattenended-upgrades" is installed and working, but i want this script to set automatic updates to daily, regardless of what machine i run it on. The machines that this script will be run on will most likely have it set to "Never"
– Tech_Person
Jan 11 at 3:43
It's long because you were heading down a more difficult road than you need to.
– user535733
Jan 11 at 4:19
so, i didnt really get a clear answer though. How exactly do i enable automatic checking for updates daily?
– Tech_Person
Jan 11 at 4:26
u-u ignores the GUI setting, and runs daily when enabled. The GUI control is older; from before the days when u-u was enabled by default. If you want standardization, there are several easy ways.
– user535733
Jan 11 at 13:36
add a comment |
Unattended upgrades are enabled by default in all Ubuntu releases 16.04 and newer.
There are three easy ways to tell if the unattended-upgrades
package is installed and working.
1) See if the package is installed. Look for "[installed]" at the end of the bottom line of output.
$ apt list unattended-upgrades
Listing... Done
unattended-upgrades/cosmic-updates,cosmic-updates,now 1.5ubuntu3.18.10.1 all [installed]
2) Check the apt timestamps for unattended-upgrades activity. Look for a timestamp by unattended-upgrades within the past day or two:
$ ls -la /var/lib/apt/periodic/
total 8
drwxr-xr-x 2 root root 4096 Sep 15 2017 .
drwxr-xr-x 5 root root 4096 Jan 1 08:24 ..
-rw-r--r-- 1 root root 0 Jan 10 07:54 download-upgradeable-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:51 unattended-upgrades-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:52 update-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:53 update-success-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:55 upgrade-stamp
3) Check the apt settings to see if Unattended Upgrades is turned on ("1") or off ("0"):
$ grep Unattended-Upgrade /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Unattended-Upgrade "1";
The repositories that unattended-upgrades uses are listed in /etc/apt/apt.conf.d/50unattended-upgrade.
- The -security repository is enabled by default in all releases of Ubuntu.
- Adding other Ubuntu repositories is trivial: Simply uncomment the appropriate line.
- Enabling -backports is discouraged, those packages are not fully tested.
- Enabling -proposed is STRONGLY DISCOURAGED, as those packages can be very risky.
If unattended-upgrades is installed and turned on, it will run daily whether you want it to or not. Only the GUI provides the option to change the period.
After you make changes you do not need to restart your system. Apt runs once daily at a random time, and reloads it's configs and sources anew each time.
Unattended upgrades are enabled by default in all Ubuntu releases 16.04 and newer.
There are three easy ways to tell if the unattended-upgrades
package is installed and working.
1) See if the package is installed. Look for "[installed]" at the end of the bottom line of output.
$ apt list unattended-upgrades
Listing... Done
unattended-upgrades/cosmic-updates,cosmic-updates,now 1.5ubuntu3.18.10.1 all [installed]
2) Check the apt timestamps for unattended-upgrades activity. Look for a timestamp by unattended-upgrades within the past day or two:
$ ls -la /var/lib/apt/periodic/
total 8
drwxr-xr-x 2 root root 4096 Sep 15 2017 .
drwxr-xr-x 5 root root 4096 Jan 1 08:24 ..
-rw-r--r-- 1 root root 0 Jan 10 07:54 download-upgradeable-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:51 unattended-upgrades-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:52 update-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:53 update-success-stamp
-rw-r--r-- 1 root root 0 Jan 10 07:55 upgrade-stamp
3) Check the apt settings to see if Unattended Upgrades is turned on ("1") or off ("0"):
$ grep Unattended-Upgrade /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Unattended-Upgrade "1";
The repositories that unattended-upgrades uses are listed in /etc/apt/apt.conf.d/50unattended-upgrade.
- The -security repository is enabled by default in all releases of Ubuntu.
- Adding other Ubuntu repositories is trivial: Simply uncomment the appropriate line.
- Enabling -backports is discouraged, those packages are not fully tested.
- Enabling -proposed is STRONGLY DISCOURAGED, as those packages can be very risky.
If unattended-upgrades is installed and turned on, it will run daily whether you want it to or not. Only the GUI provides the option to change the period.
After you make changes you do not need to restart your system. Apt runs once daily at a random time, and reloads it's configs and sources anew each time.
edited Jan 11 at 4:20
answered Jan 11 at 3:27
user535733user535733
8,25222943
8,25222943
most of this doesnt really help me, i checked to confirm that "Unattenended-upgrades" is installed and working, but i want this script to set automatic updates to daily, regardless of what machine i run it on. The machines that this script will be run on will most likely have it set to "Never"
– Tech_Person
Jan 11 at 3:43
It's long because you were heading down a more difficult road than you need to.
– user535733
Jan 11 at 4:19
so, i didnt really get a clear answer though. How exactly do i enable automatic checking for updates daily?
– Tech_Person
Jan 11 at 4:26
u-u ignores the GUI setting, and runs daily when enabled. The GUI control is older; from before the days when u-u was enabled by default. If you want standardization, there are several easy ways.
– user535733
Jan 11 at 13:36
add a comment |
most of this doesnt really help me, i checked to confirm that "Unattenended-upgrades" is installed and working, but i want this script to set automatic updates to daily, regardless of what machine i run it on. The machines that this script will be run on will most likely have it set to "Never"
– Tech_Person
Jan 11 at 3:43
It's long because you were heading down a more difficult road than you need to.
– user535733
Jan 11 at 4:19
so, i didnt really get a clear answer though. How exactly do i enable automatic checking for updates daily?
– Tech_Person
Jan 11 at 4:26
u-u ignores the GUI setting, and runs daily when enabled. The GUI control is older; from before the days when u-u was enabled by default. If you want standardization, there are several easy ways.
– user535733
Jan 11 at 13:36
most of this doesnt really help me, i checked to confirm that "Unattenended-upgrades" is installed and working, but i want this script to set automatic updates to daily, regardless of what machine i run it on. The machines that this script will be run on will most likely have it set to "Never"
– Tech_Person
Jan 11 at 3:43
most of this doesnt really help me, i checked to confirm that "Unattenended-upgrades" is installed and working, but i want this script to set automatic updates to daily, regardless of what machine i run it on. The machines that this script will be run on will most likely have it set to "Never"
– Tech_Person
Jan 11 at 3:43
It's long because you were heading down a more difficult road than you need to.
– user535733
Jan 11 at 4:19
It's long because you were heading down a more difficult road than you need to.
– user535733
Jan 11 at 4:19
so, i didnt really get a clear answer though. How exactly do i enable automatic checking for updates daily?
– Tech_Person
Jan 11 at 4:26
so, i didnt really get a clear answer though. How exactly do i enable automatic checking for updates daily?
– Tech_Person
Jan 11 at 4:26
u-u ignores the GUI setting, and runs daily when enabled. The GUI control is older; from before the days when u-u was enabled by default. If you want standardization, there are several easy ways.
– user535733
Jan 11 at 13:36
u-u ignores the GUI setting, and runs daily when enabled. The GUI control is older; from before the days when u-u was enabled by default. If you want standardization, there are several easy ways.
– user535733
Jan 11 at 13:36
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1108738%2fenable-automatic-updates-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
So to clarify, you're still looking for how to enable automatic updates and enable the "Check daily" option, right? What version of Ubuntu are you asking about?
– wjandrea
Jan 11 at 3:22
Instead of sed-ing files, you can simply place your own config file in /etc/apt/apt.conf.d. Give it a high number like "99-my-config-changes" so it takes precedence over earlier-loaded config settings. Custom configs are rarely neccessary - unattended-upgrades has sane default settings.
– user535733
Jan 11 at 3:30
I am currently using ubuntu 18.04.1 LTS, and yes i am still looking for the Check daily option
– Tech_Person
Jan 11 at 3:33
Editing sources.list files isn't directly related to updating automatically... the sources choose where to update from, but not when. And which program do you want to use/edit, unattended-upgrades, gnome update manager, cron & aptitude, cron-apt?
– Xen2050
Jan 11 at 4:43
@Xen2050 I want to edit whatever file the GUI uses when you change it manually, i want the exact same result.
– Tech_Person
Jan 12 at 5:36