1

I set root's cron to automatically run apt-get upgrade. Easy enough. Here's the specific line:

@daily (apt-get update && apt-get -y upgrade) 2>&1 > /var/log/tmp.log

However, I've been following the log file's output, and it always stops at the part of the output where it would typically (i.e. without -y) ask Do you want to continue [Y/n]?. I confirm that it didn't keep running because apt-get upgrade still shows packages needing to be updated. Why is it stopping at this point? And how do I get it to continue?

Edit:

### apt-get update output ###  

Building dependency tree...
Reading state information...
The following packages have been kept back:
  linux-generic linux-headers-generic linux-image-generic
The following packages will be upgraded:
  file libgudev-1.0-0 libmagic1 libpam-systemd libsystemd-daemon0
  libsystemd-login0 libudev1 linux-libc-dev openssh-client openssh-server
   systemd-services udev
12 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B/3,412 kB of archives.
After this operation, 16.4 kB of additional disk space will be used.

Edit 2: I shortened the command to try and isolate the problem. I also read up on man apt-get. I found a new potential flag to pass, leaving me with:

@daily apt-get -y --force-yes upgrade 2>&1 > /var/log/tmp.log

Unfortunately, I still get the same results :(

2 Answers 2

2

tldr; Don't assume any environment variables in cron (including PATH).

After a couple days, I realized I'm an idiot and put 2>&1 in the wrong place. After putting it after the log file name, it gave me the errors causing my issue:

dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 2 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin

With this new info, I finally found another post with the same issue. It turns out that cron has very limited environment variables. This was due to old attacks on cron that take advantage of said variables. This means the PATH variable never loads (indicated in the above error), and so some commands that apt-get upgrade depends on could not be run. This can be fixed by setting PATH manually in cron.

There are also some other errors about the fact that debconf needs a controlling tty. This does not prevent the command from running, but these can be suppressed by setting the DEBIAN_FRONTEND environment variable in cron.

Here it is in all its glory:

PATH=/usr/bin:/bin:/usr/sbin:/sbin
DEBIAN_FRONTEND=noninteractive
@daily apt-get -y upgrade > /var/log/tmp.log 2>&1
0

What packages are not being updated?

Are you sure you don't want apt-get dist-upgrade? The linux-image-* package for example could not be updated simply with apt-get upgrade because a new package is installed. New packages only get installed with dist-upgrade.

4
  • Yes, I'm sure. I tried addressing this when I said I confirmed there's still packages waiting to be updated after running the command manually afterwards. Regardless, even in the log output, it shows the linux-* packages as being held back with about 10 other ones shown as will be upgraded. The will be upgraded ones are not being upgraded.
    – ubomb
    Commented Apr 7, 2014 at 20:29
  • Just for the hell of it, I tried changing it to dist-upgrade, and it exhibits the same behavior.
    – ubomb
    Commented Apr 7, 2014 at 20:30
  • Editing your question and including the exact output sure would be helpful.
    – Zoredache
    Commented Apr 7, 2014 at 20:33
  • Not really sure what difference it makes (if it was something odd in the output, I would most likely have noticed it), but I added it.
    – ubomb
    Commented Apr 7, 2014 at 20:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .