Linux - NewbieThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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.
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
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
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:
tinkstersaid:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.