LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-16-2008, 12:26 PM   #1
imputerate
LQ Newbie
 
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19

Rep: Reputation: 0
'locate' utility can't find db


ubuntu, hardy beta

system crashed; rebooted; tried 'locate';

hodgson@hodgson-desktop:~$ locate .ssh

locate: `/var/lib/mlocate/mlocate.db' does not seem to be a mlocate database

what do i do?
 
Old 05-16-2008, 12:41 PM   #2
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.0 + 14.1
Posts: 4,834

Rep: Reputation: 431Reputation: 431Reputation: 431Reputation: 431Reputation: 431
Run the command 'sudo updatedb' let that complete. If you have never run the command you will not have the data base. It creates it on the first run, and then updates it when you re-run sudo updatedb.
 
Old 05-16-2008, 05:18 PM   #3
imputerate
LQ Newbie
 
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19

Original Poster
Rep: Reputation: 0
thank you cliff; that was simple and quick;

how can i get hardy to run that locatedb every day, without my having to lift a finger?
 
Old 05-16-2008, 08:27 PM   #4
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.0 + 14.1
Posts: 4,834

Rep: Reputation: 431Reputation: 431Reputation: 431Reputation: 431Reputation: 431
You can set up a cron job for updatedb. If you run locate, it will complain once the db is eight days old or older. All I do is open a konsole, and run it when I need to, or if I have done some updates or installed software, I'll run it.

Cron jobs are a bit of a learning experience. I installed Webmin and I do my configuration through Webmin. One of the many things you can do with it is cron jobs.
 
Old 05-17-2008, 02:33 AM   #5
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
Quote:
how can i get hardy to run that locatedb every day, without my having to lift a finger?
I have this file in /etc/cron.daily
Filename= slocate
Code:
#! /bin/sh

if [ -x /usr/bin/slocate ]
then
	if [ -f /etc/updatedb.conf ]
	then
		/usr/bin/updatedb
	else
		/usr/bin/updatedb -f proc
	fi
	chown root.slocate /var/lib/slocate/slocate.db
fi
The file is executable:
Code:
ls -l /etc/cron.daily/slocate
-rwxr-xr-x 1 root root 189 2006-01-07 15:44 /etc/cron.daily/slocate
It runs once every day
 
Old 05-17-2008, 02:19 PM   #6
imputerate
LQ Newbie
 
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19

Original Poster
Rep: Reputation: 0
thanks cliff and tredegar; i found this file, /etc/cron.daily/slocate;

i has evidently not been working; can you tell me why?
-----------------------------------

#! /bin/sh

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

# 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 ]
then
nice -n ${NICE:-10} /usr/bin/slocate -u
else
nice -n ${NICE:-10} /usr/bin/slocate -u -f proc
fi
chown root.slocate /var/lib/slocate/slocate.db
fi
 
Old 05-17-2008, 03:40 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Commonly those jobs run in the small hours of the morning. If
your machine isn't turned on that time of day it will never
run. The script itself is perfectly sane.



Cheers,
Tink
 
Old 05-17-2008, 05:07 PM   #8
vadkutya
Member
 
Registered: Apr 2008
Distribution: slackware 10.2
Posts: 117

Rep: Reputation: 16
you can also do an update every time you boot your system, like the linker is updated for example. just put the command in your boot script.

vadkutya
 
Old 05-25-2008, 05:31 PM   #9
imputerate
LQ Newbie
 
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19

Original Poster
Rep: Reputation: 0
s and m

about the cron.daily files for updatedb:
(see post in this thread 05-17-08 02:19 PM)

i looked for /etc/cron.daily/slocate, because the error message generated when i typed 'locate' [i.e. mlocate, not slocate] in the absence of a db for locate, mentioned slocate.db.

trouble is, 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 ]
then
if [ -f /etc/updatedb.conf ]
then
. /etc/updatedb.conf
fi

# 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 ]
then
nice -n ${NICE:-10} /usr/bin/slocate -u
else
nice -n ${NICE:-10} /usr/bin/slocate -u -f proc
fi
chown root.slocate /var/lib/slocate/slocate.db
fi

---------------------------------------
now that i've learned a little about reading scripts, this provides me with the answer to my question about why it didn't work.

i should have asked, and i am doin so now, why the mlocate script, if it was executing, didn't 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"
fi

$IONICE /usr/bin/updatedb.mlocate
---------------------------------

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

is this a bug?

here's a script, provided by our own tredegar which is innocent of any sort of s and m stand-offishness:

#! /bin/sh

if [ -x /usr/bin/slocate ]
then
if [ -f /etc/updatedb.conf ]
then
/usr/bin/updatedb
else
/usr/bin/updatedb -f proc
fi
chown root.slocate /var/lib/slocate/slocate.db
fi

thank you all for your patience; imputerate
 
Old 05-26-2008, 05:52 AM   #10
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
All I can say is that different distros do things differently.
I don't have mlocate, but
Code:
tred@vaio:~$ ls -l $(which locate)
lrwxrwxrwx 1 root root 7 2007-02-24 07:30 /usr/bin/locate -> slocate
So my distro actually uses slocate when I issue a locate command.

The best thing to do is to work out how to get your version of locate working from the command line, and then put it into a cron job.
Quote:
tinkster said:
Commonly those jobs run in the small hours of the morning. If
your machine isn't turned on that time of day it will never
run.
Correct, but my distro seems to be using anacron which checks to see if cron has "missed" any jobs because the computer was turned off. If so it tries to run them to "catch up".
More here: http://anacron.sourceforge.net/

So, about five minutes after the first boot of the day, there's some furious disk activity as my slocate database is rebuilt, log files are rotated etc.
 
  


Reply

Tags
locate, utility


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Locate, Find, and Whereis LXer Syndicated Linux News 0 03-28-2006 03:06 PM
Find/locate an exact file stefaandk Linux - General 2 12-27-2005 07:56 AM
Unable to locate 'cc' utility in path SEATU Linux - Newbie 2 10-05-2005 12:22 AM
cannot find a kernel, please locate one bobotoes Linux - Newbie 2 10-07-2004 06:15 PM
What's in my computer/Utility to find out geraldgu Linux - Software 2 12-14-2001 12:04 PM


All times are GMT -5. The time now is 07:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration