I've encountered problems when I played with system updates automation based on calling apt-get update and apt-get upgrade from crontab. I added two following lines to my crontab file:
10 * * * * apt-get update > /home/log/apt.update
12 * * * * apt-get -y upgrade > /home/log/apt.upgrade
However, the success is quite limited: update process looks ok, but apt-get upgrade
throws some kind of errors:
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages were automatically installed and are no longer required:
linux-headers-4.15.0-65 linux-headers-4.15.0-65-generic
linux-image-4.15.0-65-generic linux-modules-4.15.0-65-generic
linux-modules-extra-4.15.0-65-generic
Use 'apt autoremove' to remove them.
The following packages have been kept back:
linux-generic linux-headers-generic linux-image-generic
The following packages will be upgraded:
dotnet-host git git-man grub-common grub-pc grub-pc-bin grub2-common
intel-microcode libpcap0.8 libsqlite3-0 linux-firmware unattended-upgrades
12 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B/86.3 MB of archives.
After this operation, 8,474 kB of additional disk space will be used.
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
I belive that the last 4 lines describes problem, but still I have not idea how to fix it. I could'n replicate this behavior trying:
- sudo apt-get -y upgrade
- works perfectly
- sudo -i
then su
and then apt-get upgrade
- also works
I will be than grateful for any hint.
System version: Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-70-generic x86_64)
PATH
for processes started from root's crontab is very limited (PATH=/usr/bin:/bin
) - as you can verify for example by adding a simple cron job like/usr/bin/printenv > /tmp/cronenv
– steeldriver Dec 11 '19 at 13:12