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

1
  • I have the same problem, will see if removing autofs helps. Thanks! Commented May 1, 2013 at 8:54

8 Answers 8

32

Based on the contents of the /var/lib/dpkg/info/man-db.postinst script, the Processing triggers for man-db step is only executed if the file /var/lib/man-db/auto-update exists, which in turn is created/deleted depending on the value of the man-db/auto-update debconf setting.

This time-consuming and arguably unnecessary step can thus be safely disabled by executing the following commands:

sudo debconf-set man-db/auto-update false
sudo rm /var/lib/man-db/auto-update

If you don't have a debconf-set command, see this other answer below.

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.

8
  • 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
    Commented Dec 14, 2022 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
    Commented Dec 15, 2022 at 20:08
  • 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
    Commented Sep 10, 2023 at 17:25
  • This worked for me too but after some weeks the file appeared again... Any idea how to prevent that from happening? I wonder if that coincided with the time I upgraded to 24.04.
    – nteodosio
    Commented May 27 at 8:12
  • 1
    Thank you, Zoltan, in my 24.04 system I don't have debconf-set (that comes from ubiquity), but echo 'set man-db/auto-update false'|debconf-communicate works.
    – nteodosio
    Commented May 28 at 9:52
22

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.

6
  • 6
    Hmm, on ubuntu this wanted to remove ubuntu-standard, which seems like a bad idea
    – Kevin
    Commented Mar 13, 2021 at 1:32
  • 3
    @Kevin That is why you should never use the -y flag. I don't understand why so many people use it. Commented Sep 19, 2022 at 14:42
  • @TheRealTengri maybe it helps in a CI/CD situation as mentioned above because it's non interactive Commented Nov 4, 2022 at 14:07
  • 1
    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. 😬 Commented Aug 30, 2023 at 9: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
    Commented Oct 10, 2023 at 7: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
5
  • This is the solution and works. Commented Oct 1, 2020 at 6:33
  • didnt work for me
    – Adeerlike
    Commented Oct 13, 2020 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
    Commented Oct 18, 2020 at 2: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). Commented May 28, 2022 at 1:54
  • 1
    rm -rf /var/cache/man does also need a sudo.... Commented Jul 10, 2023 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.

1
  • 1
    The reason this is slow on WSL1 is because of slow I/O on WSL1. It is a known issue. Commented Apr 19, 2020 at 15:49
6

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.

3

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

5
  • 5
    this is not a solution
    – Habibillah
    Commented Oct 19, 2021 at 17:09
  • 1
    @Habibillah i've edited my response to have a solution
    – Cherona
    Commented Oct 20, 2021 at 15:28
  • I have this problem on a Raspberry Pi with a brand new SD-card.
    – bomben
    Commented Jul 4, 2022 at 17:44
  • @bomben SD cards are extremely slow
    – Cherona
    Commented Jul 21, 2022 at 14:43
  • 2
    @Habibillah I actually came here because I have exactly this issue on Google Cloud, and was looking for a reason/solution Commented Nov 3, 2022 at 22:19
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.

4
  • 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
    Commented Apr 27, 2022 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
    Commented Apr 29, 2022 at 3:20
  • 1
    Don't do this. man-db has a flag file to disable the automatic update. See @Zoltan's answer.
    – Tom
    Commented Dec 16, 2022 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 Processing triggers for man-db (2.9.1-1) ... Not building database; man-db/auto-update is not 'true'. on every apt update.
    – dave58
    Commented Dec 18, 2022 at 0:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .