So basically, I'm trying to delete the files:
/var/lib/mysql/db/nomNomina2.*
and when I look for them with locate, I get the following output:
/var/lib/mysql/db/nomNomina2.MYD
/var/lib/mysql/db/nomNomina2.MYI
/var/lib/mysql/db/nomNomina2.frm
but then I try to
$ rm -fv /var/lib/mysql/db/nomNomina2.frm
I get no output, but the files still show when using locate.
Notice that I can create and delete a file with the same filename in the same location, but it will still show when using locate, and I won't be able to create another table with the same name.
Any ideas what could be causing this? filesystem mess? how to correct it?
Best Answer
locate
is not dependable for live, current information about what files are present on your system. Information is cached in a database.Also consider the famous line, with link:
For actual current information on what files/directories exist on your box right now, use
ls
orfind
orstat
ortest -e filename && echo it is there
or evenprintf %s\\n *
. Pretty much anything exceptlocate
will give you up-to-date information about your filesystem.See also
LESS=+/BUGS man locate
which (on my system) reads in part:You can run
updatedb
, but honestly if you know exactly where the files are and you are usinglocate
to find them...you are simply doing it wrong.locate
tells you a path. It tells you nothing about the existence or nonexistence of files at that path. If you already know the path to the file, you don't needlocate
, do you?The purpose of locate is to "find filenames quickly", not necessarily accurately or dependably.
Note: I'm not saying "don't use
locate
." It does have a purpose, when you have no idea where on your system a certain file might be. But once you get the pathname fromlocate
, it has served its purpose and you now need to use other tools to examine/verify/etc. the file you've found.