Make apt-get update and upgrade automate and unattended
Use the -y option to apt-get to have it not ask. From man apt-get
:
-y, --yes, --assume-yes
Automatic yes to prompts; assume "yes" as answer to all prompts and
run non-interactively. If an undesirable situation, such as
changing a held package, trying to install a unauthenticated
package or removing an essential package occurs then apt-get will
abort. Configuration Item: APT::Get::Assume-Yes.
You can also set the DEBIAN_FRONTEND env variable
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
Well, maybe you are using the wrong tool. unattended-upgrades
package installs security upgrades in daily basis (can be configured), you can configure what packages to upgrade or not upgrade, etc. Can be installed using:
sudo apt-get install unattended-upgrades
From man unattended-upgrades
:
The configuration is done via the apt configuration mechanism. The default configuration file can be found at /etc/apt/apt.conf.d/50unattended-upgrades
while the previous answers are informative they don't circumvent the issue of input required by human means during upgrade
. therefore, i am using the following:
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
sudo -E apt-get -qy update
sudo -E apt-get -qy -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade
sudo -E apt-get -qy autoclean
to include 'distribution' upgrades like kernels use the dist-upgrade
command.
please see the manpgage of dpkg
for in-depth information on these parameters.
important note: calling sudo
including the -E
parameter is required:
Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the user does not have permission to preserve the environment.
otherwise, the EXPORT
statements will not affect the calls of apt-get
!
credit goes to Remy van Elst! thanks!