38

When running sudo aptitude upgrade, the console freezes for long after almost every package upgrade with a message "Processing triggers for man-db ...". What could be the problem and how can I fix it?

Ubuntu version: 12.04 (both Server and Xubuntu)

Thanks in advance.


Update: It looks like this problem is related to package autofs upon my further tests. Removing autofs resolved the issues. No idea why. I then have to use soft links instead of autofs for my file system to avoid this issue (and other two issues posted here as well).

slacktty
  • 411

8 Answers8

30

The Processing triggers for man-db step is only executed if the file /var/lib/man-db/auto-update exists. This is an empty file with the sole purpose of controlling this behavior, so it can be safely removed to disable this time-consuming and arguably unnecessary process.

I personally disable this trigger on all of my systems. While the man-db cache is supposed to enhance the manual page system's speed and functionality, I have not experienced any noticeable performance degradation or functional problem after disabling the trigger.

Zoltan
  • 677
  • 6
    Oh dear God why isn't this the accepted answer? How many years of my life have I spent waiting for man-db triggers to update after packages are installed? – Tom Dec 14 '22 at 12:27
  • 5
    @Tom The reason this answer did so poorly in terms of votes is that I posted it 9 years after the question was asked and also after it had already recieved several answers that already gained lots of votes by this time. But I'm glad that at least one person stumbled upon this answer on the bottom of the page and found it useful. :) – Zoltan Dec 15 '22 at 20:08
  • another person :D – suvigyavijay Jan 10 '23 at 08:31
  • Thanks for the suggestion, works great @Zoltan! – Bruno Mar 27 '23 at 23:04
  • This is awesome! sudo rm /var/lib/man-db/auto-update Processing triggers for man-db (2.9.4-2) ... Not building database; man-db/auto-update is not 'true'. – ski_squaw Sep 10 '23 at 17:25
23

Caution: Running the below command will remove integral parts of Ubuntu, such as the ability to read manual pages with the man command and related utilites such as apropos and whatis. In addition, it removes the ubuntu-standard metapackage, which will in turn mark an additional number of packages as manually installed. Follow this advice with extreme caution.

Might be helpful for someone: I ran into this issue on our CI regularly.

Just execute the following:

sudo apt-get remove --purge man-db

The command removes the man-db package completely, which in our case on CI, was completely useless anyway.

Artur Meinild
  • 26,018
Andreas
  • 347
  • 6
    Hmm, on ubuntu this wanted to remove ubuntu-standard, which seems like a bad idea – Kevin Mar 13 '21 at 01:32
  • 3
    @Kevin That is why you should never use the -y flag. I don't understand why so many people use it. – TheRealTengri Sep 19 '22 at 14:42
  • @TheRealTengri maybe it helps in a CI/CD situation as mentioned above because it's non interactive – ᴍᴇʜᴏᴠ Nov 04 '22 at 14:07
  • I don't understand why this has so many upvotes. Removing the ability to read man pages altogether doesn't seem like a suitable solution to me. – Artur Meinild Aug 30 '23 at 09:57
  • @ArturMeinild Conflict of interest . Depends on whether your desire to read man pages in the terminal instead of on the internet outweighs your frustration from watching some old software take longer to add a bit of text to a database than your system did to install the thing you actually asked for. – c z Oct 10 '23 at 07:53
15

It's possible the mandb index is corrupted.

check the index and recreate it

sudo mandb -t
rm -rf /var/cache/man
sudo mandb -c
hbt
  • 258
  • 2
  • 6
  • This is the solution and works. – Bhikkhu Subhuti Oct 01 '20 at 06:33
  • didnt work for me – Adeerlike Oct 13 '20 at 21:15
  • 1
    I'm not sure it's necessary to remove the cache prior to invoking mandb with the -c flag. According to the man page: -c, --create By default, mandb will try to update any previously created databases. If a database does not exist, it will create it. This option forces mandb to delete previous databases and re-create them from scratch, and implies --no-purge. This may be necessary if a database becomes corrupt or if a new database storage scheme is introduced in the future. – chb Oct 18 '20 at 02:25
  • 1
    For me, the -t/--test action took half an hour. I’d recommend running it in tmux (or any persistent terminal), instead of plain SSH (which might be interrupted). – Franklin Yu May 28 '22 at 01:54
  • 1
    rm -rf /var/cache/man does also need a sudo.... – Georg Mavridis Jul 10 '23 at 14:42
6

I had something similar just after installing Ubuntu 18.04 on Windows Subsystem for Linux and running update and upgrade: it got stuck at processing triggers for man-db (2.8.3-2). And also later, after running

sudo apt install python3-pip

My solution: I just waited. In the second case even some 15 minutes. I do not know whether this is normal, as I am very new to Linux. But this so people just know another experience if they run into the same problem.

Oxfos
  • 69
4

The man-db update trigger is controlled by a hidden flag in debconf, which is cached on the filesystem in the path /var/lib/man-db/auto-update. That cached flag file is synced from the debconf database in the man-db postinst script here: https://sources.debian.org/src/man-db/2.11.2-2/debian/postinst/#L70-L79.

The right way to toggle man-db's auto-update flag is to change the value of man-db/auto-update to false in the debconf database and re-run the man-db postinst script that syncs the value to disk. Run the following commands as root:

echo "set man-db/auto-update false" | debconf-communicate; dpkg-reconfigure man-db

This flag was originally introduced to avoid rebuilding the man-db database on Debian/Ubuntu build daemons; see Debian bugs 554914 and 579075 for details.

edmonds
  • 41
  • 1
2

Processing triggers for man-db is I/O bound, and can be painfully slow if you are on a HDD, or Google Cloud's default disk storage tier.

Upgrade your disk

Cherona
  • 203
  • 2
  • 6
1

I have had the same problem when I was installing apache web server on my digital ocean droplet. After waited a bit, I simply just stop the process and rerun the command. It shows the apache is already installed and it worked. I hope it can still help.

-1

Since I sometimes need the man pages.

And since there doesn't seem to be a stand-alone 'man' package, I can't simply remove 'man-db'.

My solution, for better or worse, was to move the 'mandb' executable out of the way and substitute in a copy of 'true'

On my system:

sudo mv /usr/bin/mandb /usr/bin/mandb-OFF
sudo cp -p /bin/true /usr/bin/mandb 
sudo rm -r /var/cache/man

This is easy to undo if the need arises. And I deleted the /var/cach/man directory, as it is no longer needed and recovered megabytes of space.

Any 'man' pages you need are grabbed from the source man directory and decompressed on the fly. No more caching means a slight inefficiency, but with today's speeder processors and disks, its minimal.

A caveat: Anytime you get a man-db package update, your modifications will be overwritten. Either apt-hold the 'man-db' package or be prepared to redo this at the whim of the 'man-db' package maintainers and distribution managers.

After this mod, you will still see the line "Processing triggers for man-db" fly by but it's a zero second thing. :-)

Good Luck.

dave58
  • 191
  • 2
    Use dpkg-divert to move mandb executable elsewhere. Use update-alternatives to link /bin/true to mandb. Then you don't have to update anything after package upgrade – midenok Apr 27 '22 at 20:53
  • @midenok : Is the man-db package 'alternatives' aware? IMHO, I don't think so. No mention of alternative checks in its pre/post installation scripts. It looks like any update will simply override any /dev/null or /etc/alternative links in its way. And the 'dpkg-divert' concept tends to blow away the basic Linux KISS, do one thing and do it well principal. I think I'll stay with just dev-nulling or 'true'ing /usr/bin/mandb – dave58 Apr 29 '22 at 03:20
  • Don't do this. man-db has a flag file to disable the automatic update. See @Zoltan's answer. – Tom Dec 16 '22 at 12:42
  • @Tom Following @Zoltan's answer (removing the /var/lib/man-db/auto-update flag file) will stop the auto updates to the /var/cache/man directory but appears to have no effect on the periodic cron jobs which rebuild the (useless IMHO) /var/cache/man directory. I want to get rid of the /var/cache/man directory as it is pretty useless when using a modern CPU.

    Also note that just removing the /var/lib/man-db/auto-update flag file will cause the warning

    Not building database; man-db/auto-update is not 'true'.````
    on every apt update.
    
    – dave58 Dec 18 '22 at 00:15