View Full Version : [ubuntu] hardy: locate, s and m

May 27th, 2008, 05:30 AM
a few weeks after installing hardy, i tried to run 'locate'; an error message complained about slocate.db;

turns out that the slocate cron job doesn't work if mlocate is installed, which it is on ubuntu hardy; here's the script:

#! /bin/sh

if [ -x /usr/bin/slocate ] && [ ! -x /usr/bin/mlocate ]
if [ -f /etc/updatedb.conf ]
. /etc/updatedb.conf

# Adjust I/O priority of current process (default: best effort)
ionice -c ${IONICE_CLASS:-2} -n ${IONICE_PRIORITY:-7} -p $$

if [ -f /etc/updatedb.conf ]
nice -n ${NICE:-10} /usr/bin/slocate -u
nice -n ${NICE:-10} /usr/bin/slocate -u -f proc
chown root.slocate /var/lib/slocate/slocate.db


why didn't the etc/cron.daily/mlocate script, if it was executing, fix it so my 'locate' command would work.

here it is:
#! /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"

$IONICE /usr/bin/updatedb.mlocate

is it the case that 'locate' uses the /var/lib/slocate/slocate.db instead of /var/lib/mlocate/mlocate.db?

hodgson@ubu:~$ ls -l $(which locate)
lrwxrwxrwx 1 root root 24 2008-03-25 20:59 /usr/bin/locate -> /etc/alternatives/locate
hodgson@ubu:~$ which locate

is this a bug?

should i fix it so that 'locate' runs slocate, and then uninstall mlocate? how?

what's a newbie to do?

May 27th, 2008, 06:28 AM
What's the difference between slocate and mlocate?

May 27th, 2008, 06:50 AM
I'm not familiar with the differences between the two but, you could try:

sudo update-alternatives --config locate

May 31st, 2008, 02:22 PM
Do I really need any of them? What do they do? I mean, they just clog up my proccessor and harddrive from time to time... Can I just disable them by adding a . (period) in cron.daily to their filenames without breaking my system?

May 31st, 2008, 02:35 PM
You don't need them. Some distros do not even install them by default. Their purpose is to make it easier to find any files on your system. Updatedb periodically index all of the files on the system, and the m/slocate commands reference that index in order to show you where a file is located. You can pretty much do it manually with the find command; you would just have to wait longer for the results. I find the locate command to be very helpful at times. The indexing by default should be running at a time of the day when nobody is usually active on the computer; I have never seen a performance hit from it.

May 31st, 2008, 02:51 PM
As a file search app, you might try catfish

sudo apt-get install catfishThen goto Aplications->Accessories->Catfish to search files.