This server runs Debian 7 and I'm facing a big mystery.
Here are my cron tasks:
$ sudo crontab -e
42 15 * * * apt-get -y update >> /var/log/my-apt-update.txt
52 15 * * * apt-get -y upgrade >> /var/log/my-apt-upgrade.txt
I added the ">> /var/log/my-apt-upgrade.txt"
part because I try to understand why my system never gets upgraded.
The cron tasks run. Everyday I have these lines in /var/log/syslog:
Nov 14 15:42:01 myhostname /USR/SBIN/CRON[3374]: (root) CMD (apt-get -y update >> /var/log/my-apt-update.txt)
Nov 14 15:52:01 myhostname /USR/SBIN/CRON[3394]: (root) CMD (apt-get -y upgrade >> /var/log/my-apt-upgrade.txt)
And /var/log/my-apt-upgrade.txt has paragraphs like this (I only show the last two days):
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be upgraded:
file libmagic1
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/256 kB of archives.
After this operation, 110 kB disk space will be freed.
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be upgraded:
file libmagic1
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/256 kB of archives.
After this operation, 110 kB disk space will be freed.
As you can see, the packages "file" and "libmagic1" should have been upgraded the first day. But they weren't. So the second day, they're mentioned again. But not upgraded.
And today, if I run
$ sudo apt-get -y upgrade
the packages "file" and "libmagic1" are mentioned again and they get upgraded (finally).
So, as you can see, I can upgrade manually. But these packages should have been upgraded earlier when the cron task ran.
Any clue about this mystery?
Addition Sat Nov 15 11:48:
here's what appears in my /var/log/apt/history.log around the time of the cron jobs.
Start-Date: 2014-11-13 15:52:03
Commandline: apt-get -y upgrade
Upgrade: file:amd64 (5.11-2+deb7u5, 5.11-2+deb7u6), libmagic1:amd64 (5.11-2+deb7u5, 5.11-2+deb7u6)
Error: Sub-process /usr/bin/dpkg returned an error code (2)
End-Date: 2014-11-13 15:52:03
Start-Date: 2014-11-14 15:52:03
Commandline: apt-get -y upgrade
Upgrade: file:amd64 (5.11-2+deb7u5, 5.11-2+deb7u6), libmagic1:amd64 (5.11-2+deb7u5, 5.11-2+deb7u6)
Error: Sub-process /usr/bin/dpkg returned an error code (2)
End-Date: 2014-11-14 15:52:03
The same kind of message occurs in the /var/log/apt/history.log for different packages. For example, earlier this month, the "wget" package needed some update (I had tried with the -qq option this time but this option doesn't seem to make any difference).
Start-Date: 2014-11-03 15:52:02
Commandline: apt-get -y -qq upgrade
Upgrade: wget:amd64 (1.13.4-3+deb7u1, 1.13.4-3+deb7u2)
Error: Sub-process /usr/bin/dpkg returned an error code (2)
End-Date: 2014-11-03 15:52:02
Start-Date: 2014-11-04 15:52:02
Commandline: apt-get -y -qq upgrade
Upgrade: wget:amd64 (1.13.4-3+deb7u1, 1.13.4-3+deb7u2)
Error: Sub-process /usr/bin/dpkg returned an error code (2)
End-Date: 2014-11-04 15:52:03
Start-Date: 2014-11-05 15:52:03
Commandline: apt-get -y -qq upgrade
Upgrade: wget:amd64 (1.13.4-3+deb7u1, 1.13.4-3+deb7u2)
Error: Sub-process /usr/bin/dpkg returned an error code (2)
End-Date: 2014-11-05 15:52:03
sudo crontab -e
, so it opens root's crontab.sudo apt-get -y upgrade
didn't ask for any user input and worked like a charm. /var/log/dpkg.log has nothing around the cronjobs time. However /var/log/apt/history.log contains errors. I'm editing my original post to add the errors from /var/log/apt/history.log.