After checking on how to make updates automatic with crontab, I've edited mine, as root, adding the following line:

00 11 * * * /usr/bin/apt-get upgrade -q -y >> /var/log/apt-upgrade.log

Now, if I manually run apt-get upgrade some minutes later, it'll show that it didn't install any of the upgrades. The log does not report any errors at all, nor warnings. It's just a common list

Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be upgraded:
  binutils fontconfig fontconfig-config gnupg gpgv libcurl3
  libcurl4-openssl-dev libfontconfig1 libgcrypt11 libgcrypt11-dev libgd2-xpm
  libidn11 libidn11-dev libperl5.14 libpq5 libsqlite3-0 libssl-dev libssl-doc
  libssl1.0.0 libtiff4 linux-image-3.2.0-4-amd64 linux-libc-dev openjdk-7-jre
  openjdk-7-jre-headless openssh-client openssh-server openssl perl perl-base
  perl-modules ssh
31 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/93.7 MB of archives.
After this operation, 613 kB of additional disk space will be used.

Other things I've also tried (not all at the same time, obviously), with no results:

00 11 * * * apt-get upgrade -q -y >> /var/log/apt-upgrade.log
00 11 * * * root /usr/bin/apt-get upgrade -q -y >> /var/log/apt-upgrade.log
00 11 * * * apt-get upgrade -y >> /var/log/apt-upgrade.log

And nothing happens, no upgrades actually get installed. What am I doing wrong?

  • Have you tried redirecting even the STDERR to a file ? Just use <command> &> /var/log/apt-upgrade_both.log – Echoes_86 Oct 6 '16 at 15:48

You need to set DEBIAN_FRONTEND=noninteractive. I seem to recall it was a bit tricky to find, since it's actually an option for debconf, not apt-get. However, it's mentioned e.g. here, and of course in the manual of debconf.

So, make a script that contains

DEBIAN_FRONTEND=noninteractive apt-get upgrade -q -y 

and run that from cron. And remember to run apt-get update too.

Of course perhaps you should be using unattended-upgrades or something that's especially designed for this.

But I have one Debian machine using this script, and it works ok:

apt-get -q -q  update 
if apt-get -s upgrade | grep -q "0 upgraded" ; then
        DEBIAN_FRONTEND=noninteractive apt-get -y -q upgrade

The first apt-get -s is there to suppress the output and useless email in case there's nothing to upgrade.

Similar question on askubuntu.

  • That didn't work. Called the script from crontab 00 16 * * * /usr/share/apt-uu.sh , waited a bit, ran apt-get upgrade manually and the list was still there, no upgrade happened. – Arthur Oct 6 '16 at 19:10
  • @Arthur, just to double-check, does the script run correctly? You've set in in root's crontab and the script has execute permissions? Also, I can't remember what happens without setting DEBIAN_FRONTEND, but I think apt-get should run partially, so you should be getting some output in the email that cron sends. – ilkkachu Oct 6 '16 at 20:37

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.