Fixing long boot time caused by mlocate and man-db indexing

tutorial
boot

#1

I can’t recall when, but my system at a point become slow at boot.
First thing I did was to check the boot performance using:

systemd-analyze blame

This told me that the systemd timers ‘mandb.timer’ and ‘updatedb.timer’ where slowing down my boot time because they were executed on every reboot. That because the timer was set to run at midnight, and if you turn off your PC the timer will run again and again.

To check all the active timers you’ll write:

systemctl list-timers --all

The fix is very simple, move to the directory /etc/systemd/system/:

cd /etc/systemd/system/

Then copy the original timers file:

sudo cp /usr/lib/systemd/system/man-db.timer .
sudo cp /usr/lib/systemd/system/updatedb.timer .

Now edit them (as root), changing the ‘OnCalendar=daily’ to ‘OnCalendar=weekly’:

sudo nano man-db.timer

So ‘man-db.timer’ goes from:

[Unit]
Description=Daily man-db cache update

[Timer]
OnCalendar=daily
AccuracySec=1d
Persistent=true

To:

[Unit]
Description=Daily man-db cache update

[Timer]
OnCalendar=weekly
AccuracySec=1d
Persistent=true

Do the same for ‘updatedb.timer’. At your next reboot the boot time will be faster.
You can check the timers enabled in your system using this command:

 systemctl list-timers --all

On my system it gives this output:

NEXT                         LEFT                LAST                         PASSED       UNIT                   
mer 2016-11-02 00:00:00 CET  12h left            mar 2016-11-01 07:48:41 CET  3h 18min ago logrotate.timer        
mer 2016-11-02 00:00:00 CET  12h left            mar 2016-11-01 07:48:41 CET  3h 18min ago shadow.timer           
mer 2016-11-02 08:04:16 CET  20h left            mar 2016-11-01 08:04:16 CET  3h 3min ago  systemd-tmpfiles-clean.
lun 2016-11-07 00:00:00 CET  5 days left         lun 2016-10-31 08:35:02 CET  1 day 2h ago man-db.timer           
lun 2016-11-07 00:00:00 CET  5 days left         lun 2016-10-31 08:35:02 CET  1 day 2h ago updatedb.timer         
gio 2016-12-01 00:00:00 CET  4 weeks 1 days left mar 2016-11-01 07:48:41 CET  3h 18min ago pamac-cleancache.timer 
gio 2016-12-01 00:00:00 CET  4 weeks 1 days left mar 2016-11-01 07:48:41 CET  3h 18min ago pamac-mirrorlist.timer 

Hope this helps! :wink:


KDE runs faster than XFCE on my netbook
#2

Hi. I also noticed large boot times because of updatedb and mandb, but it happens only once a day. If you boot more than once a day, they don’t slow down any more. Your solution is OK, but that means search databases will be outdated by up to one week. Yet if you don’t need man pages or don’t search recent files, that is up to you.


#3

Yes, I boot every day and the slowdown is annoying. Another solution could be to set the timers to start some minutes after the boot is completed.


#4

Or not at midnight, but rather during hours you machine will be on, but perhaps not in use, like dinner time.

Personally, I never turn mine off. The monitors go off, but the machines keep running. The power usage is quite low that way, and excess heat in the office this time of year is welcome.


#5

Also that tasks run in background so you can use the computer before they finish while systemd counts them as a part of boot time.


#6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.


#7