'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? |
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.
|
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? |
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. |
Quote:
Filename= slocate Code:
#! /bin/sh Code:
ls -l /etc/cron.daily/slocate |
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 |
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 |
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 |
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 |
All I can say is that different distros do things differently.
I don't have mlocate, but Code:
tred@vaio:~$ ls -l $(which locate) 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:
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. |
All times are GMT -5. The time now is 04:57 PM. |