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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-16-2008, 12:26 PM
|
#1
|
|
LQ Newbie
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19
Rep:
|
'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?
|
|
|
|
05-16-2008, 12:41 PM
|
#2
|
|
Senior Member
Registered: Nov 2002
Location: Toronto Canada
Distribution: Slackware 14.0
Posts: 4,617
|
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.
|
|
|
|
05-16-2008, 05:18 PM
|
#3
|
|
LQ Newbie
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19
Original Poster
Rep:
|
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?
|
|
|
|
05-16-2008, 08:27 PM
|
#4
|
|
Senior Member
Registered: Nov 2002
Location: Toronto Canada
Distribution: Slackware 14.0
Posts: 4,617
|
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.
|
|
|
|
05-17-2008, 02:33 AM
|
#5
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
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
|
|
|
|
05-17-2008, 02:19 PM
|
#6
|
|
LQ Newbie
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19
Original Poster
Rep:
|
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
|
|
|
|
05-17-2008, 03:40 PM
|
#7
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
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
|
|
|
|
05-17-2008, 05:07 PM
|
#8
|
|
Member
Registered: Apr 2008
Distribution: slackware 10.2
Posts: 117
Rep:
|
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
|
|
|
|
05-25-2008, 05:31 PM
|
#9
|
|
LQ Newbie
Registered: May 2006
Location: houston/malibu
Distribution: ubuntu
Posts: 19
Original Poster
Rep:
|
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
|
|
|
|
05-26-2008, 05:52 AM
|
#10
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:21 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|