Uggh. My Ubuntu server’s updatedb.mlocate process is loud as heck and runs *forever*.

I haven’t noticed a performance decrease, as the job is set to run at a fairly low priority. But since I sit near the server, it’s annoying to listen to the hard drive churn for hours and hours. All I wanted to do was re-schedule the job to run when I’m not around. I figured that the job was being kicked off by root’s cron file, but I figured wrong.

After some investigation, I learned the following:

  • The job parameters are listed in /etc/cron.daily/mlocate.
  • #! /bin/sh

    set -e

    [ -x /usr/bin/updatedb.mlocate ] || exit 0

    # See ionice(1)
    if [ -x /usr/bin/ionice ]; then
    IONICE=”/usr/bin/ionice -c3″
    fi

    $IONICE /usr/bin/updatedb.mlocate

  • The files in /etc/cron.daily are kicked off by /etc/crontab, not by root’s crontab. For some reason, Ubuntu’s default install runs this process around 6am. Changing this file allowed me to make the job run at 3am.
  • # /etc/crontab: system-wide crontab
    # Unlike any other crontab you don’t have to run the `crontab’
    # command to install the new version when you edit this file
    # and files in /etc/cron.d. These files also have username fields,
    # that none of the other crontabs do.

    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

    # m h dom mon dow user command
    17 * * * * root cd / && run-parts –report /etc/cron.hourly
    25 3 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
    47 3 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly )
    52 3 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )
    #

  • updatedb can be configured to ignore certain paths – since my machine has a number of drives used for backups, I wanted to exclude those from the updatedb job. I accomplished this by editing /etc/updatedb.conf and adding to the PRUNEPATHS listing. Adding paths to the PRUNEPATHS option instructs updatedb to exclude those paths from indexing.
  • PRUNE_BIND_MOUNTS=”yes”
    PRUNEPATHS=”/tmp /var/spool /media /mnt/backup”
    PRUNEFS=”NFS nfs nfs4 afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre_lite tmpfs usbfs udf rpc_pipefs”