Solution 1:

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.

Solution 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.

Solution 3:

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.

Solution 4:

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.

Solution 5:

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.