20

I saw a lot of questions regarding this, but mine seems a little different.

Here's what I receive:

/etc/cron.weekly/apt-xapian-index:
FATAL -> Failed to fork.
run-parts: /etc/cron.weekly/apt-xapian-index exited with return code 100

and

/etc/cron.daily/apt:
FATAL -> Failed to fork.

and

/etc/cron.daily/apt:
DB Update failed, database locked

I always have at least 600 MB of free RAM. If I try to manually run sudo /etc/cron.daily/apt nothing happens.. the shell hangs.

What could be the problem?

EDIT: Ubuntu Server 14.04

MultiformeIngegno
  • 1,687
  • 9
  • 26
  • 31

5 Answers5

27

I've seen this message a lot. In all cases, "FATAL -> Failed to fork." meant that there was not enough memory left for the apt cron job to run. Increase free memory for this cron job.

Nils Toedtmann
  • 3,342
  • 5
  • 26
  • 36
  • 3
    Thank you. A "reboot now" freed up my memory issue and then the standard apt-get commands got me back on track. – Ryan Sep 20 '19 at 06:17
2

None of the suggested fixes worked in my situation. I still got the error message DB Update failed, database locked every day from the daily cron job. But uninstalling apt-xapian-index package finally solved the problem. The source of that error message is in the /etc/cron.daily/apt script which tries to run update-apt-xapian-index which is provided by the apt-xapian-index package.

I wrote a little blog post about the "DB Update failed" issue from my point of view.

sebix
  • 4,313
  • 2
  • 29
  • 47
2

I had this exact same issue on one Ubuntu 14.04 VPS and not another, so I realized that I didn't have a working swap on the one that was failing.

It turns out that everything was configured correctly but that all I had to do was apt-get install cryptsetup and reboot.

If you're constrained by server resources like me (512 MB RAM), I feel like it would be a good idea to keep apt-xapian-index, it's not well-documented but I imagine that things like apt-cache search would run slower without it.

That may at least fix the failed to fork error, not sure if there's any alternative to removing apt-xapian-index in the case of the DB error.

4oo4
  • 303
  • 3
  • 10
  • I found that I also didn't have swap defined on my Bitnami server on Azure. Not sure if installing cryptsetup would help. Instead, I followed the instructions here to add a swap file: https://docs.bitnami.com/installer/faq/linux-faq/#what-is-swap. – Mark Berry Dec 06 '17 at 00:58
1

I had the same issue with /etc/cron.daily/apt in Ubuntu 12 and 14 arm, but running the script from the shell succeeded. I solved it thanks to https://serverfault.com/a/191051/243172 by adding the line

ulimit -s unlimited

at the beginning of the script.

csanchez
  • 121
  • 4
1

The reason your shell seems to hang when you run sudo /etc/cron.daily/apt is the call to random_sleep(). If you comment it out (on my Ubuntu 14.04, it was line 425), you can at least confirm that the script works when you run it interactively.