Cronjob 升级 gitlab-ce 失败

Cronjob 升级 gitlab-ce 失败

我正在尝试“自动更新”gitlab。我创建了一个 shell 脚本,用于检查更新、在更新可用时安装并通过电子邮件发送结果。当我以 root 身份从 bash 启动脚本时,这一切都可以在终端上完美运行。因此,我安排了该作业crontab -e并将其设置为每天运行。

我不应该这是我个人的、家庭的 gitlab 服务器,上面没有任何非常重要的东西。我永远不会在实际的生产环境中这样做。

更新过程的输出通过管道传送到日志文件。每当 cronjob 运行时都会失败。日志文件的输出如下:

Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be upgraded:
  gitlab-ce
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 357 MB of archives.
After this operation, 2,778 kB of additional disk space will be used.
Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/debian stretch/main amd64 gitlab-ce amd64 9.3.8-ce.0 [357 MB]
apt-listchanges: Reading changelogs...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 357 MB in 17s (20.3 MB/s)
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
E: Sub-process /usr/bin/dpkg returned an error code (2)

这到底是怎么回事?我注意到它找不到东西等,但 cronjob 应该像root我将其添加为 root 一样运行?

除了一些检查、通过电子邮件发送结果等之外,shell 脚本本质上还运行:

apt-get install --only-upgrade gitlab-ce &>> $LOGFILE

我该如何解决?

相关内容