1

I'm trying to "auto-update" gitlab. I created a shell-script that checks for updates, installs when an update is available and e-mails the results. This all works perfectly fine from a terminal when I start the script from bash as root. So I scheduled the job with crontab -e and set it to run daily.

I should not this is my personal, home, gitlab server with nothing of very of importance on it. I would never do this in an actual production environment.

The output of the update process is piped to a logfile. Whenever the cronjob runs it fails. The output of the logfile is as follows:

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)

What's going on here exactly? I notice it can't find stuff etc. but the cronjob should be ran as root since I added it as root?

Besides some checks, e-mailing of outcomes etc. the shellscript, essentially, runs:

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

How do I fix this?

  • Cron sets up its own shell environment differently from the default. Related: unix.stackexchange.com/a/38956/135943 – Wildcard Jul 21 '17 at 1:17
  • Add an echo "$PATH" to your script, and I suspect you'll find that /sbin and/or /usr/sbin is missing. Just like the error message says... – derobert Jul 21 '17 at 1:18
  • Why don't you use unattended-upgrades for this? – muru Jul 21 '17 at 2:16
  • @muru: I do use unattended-upgrades but I want gitlab to be scheduled at different times, have some more control over email etc. – RobIII Jul 21 '17 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.