从 crontab 运行 apt-get update & upgrade 时出现问题

从 crontab 运行 apt-get update & upgrade 时出现问题

我在使用基于从 crontab 调用 apt-get update 和 apt-get upgrade 的系统更新自动化时遇到了问题。我在 crontab 文件中添加了以下两行:

10 * * * * apt-get update > /home/log/apt.update
12 * * * * apt-get -y upgrade > /home/log/apt.upgrade

然而,成功是相当有限的:更新过程看起来正常,但apt-get upgrade会引发某些错误:

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

我相信最后 4 行描述了问题,但我仍然不知道如何修复它。我无法复制此行为尝试: - sudo apt-get -y upgrade- 完美运行 -sudo -i然后su然后apt-get upgrade- 也有效

如有任何提示我将不胜感激。

系统版本:Ubuntu 18.04.3 LTS(GNU/Linux 4.15.0-70-generic x86_64)

相关内容