Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: A way to check on a Spotlight indexing problem System 10.4
Tiger only hintSpotlight kept indexing my home folder (protected by File Vault) never stopped trying to index it, and was therefore unusable. To find out what Spotlight was up to, I ran this command in the Terminal:
lsof | grep mdimport | grep /Users/`whoami`
I then saw that it was choking on old corrupted files, which I removed -- or if it chokes on a particular directory, you can add this directory to the Privacy tab of the Spotlight preferences pane. Hope this helps
  • Currently 2.20 / 5
  You rated: 1 / 5 (5 votes cast)

10.4: A way to check on a Spotlight indexing problem | 11 comments | Create New Account
Click here to return to the '10.4: A way to check on a Spotlight indexing problem' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: A way to check on a Spotlight indexing problem
Authored by: BWhaler on Jun 15, '05 10:39:05AM

I'm sorry to be so thick-headed, but I don't understand this hint.

I typed in this command in Terminal, and got a list of files (mostly ds_store files reflecting the trash, desktop, and preferences os_store)

What does that mean? Are those the files which are corrupt? If so, how do I fix it?

I have a lot of problems with Spotlight not finding everything, so any help would be most appreciated...



[ Reply to This | # ]
Use the terminal or path finder to delete them
Authored by: PopMcGee on Jun 16, '05 06:01:36AM
ds_store are not that particulary important: delete them and you have to set your finder preferences anew for this folder. So just go ahead and delete them, using the terminal (cd + rm) or path finder.


[ Reply to This | # ]

10.4: A way to check on a Spotlight indexing problem
Authored by: XCool on Jun 15, '05 11:07:06AM

I tried that hint, and got nothing; which I suppose means my Spotlight indexes are fine.

Thanks for the great tip!


[ Reply to This | # ]
additional info that might help
Authored by: fracai on Jun 15, '05 12:30:36PM
This hint could use some explaining as to what is actually going on here.

lsof is "LiSt Open Files" man lsof for more info basically, it lists out all files that are in use by open apps, background tasks, etc

grep searches for matches so grep mdimport is looking for the task that updates the Spotlight index

grep /Users/`whoami` could be replaced by grep /Users/ whoami reports your logged in user name and putting this in back tics runs the command before executing the grep command
an even easier way would be to run grep ~/ the ~/ expands to the location of your home folder

so in sum:

this command lists files currently being indexed for the Spotlight database, limited to files that are under your home folder

this will not list out corrupt files.

if you're experiencing trouble or slow speed with Spotlight, this might show you that Spotlight is spending a lot of time trying to index a very large or corrupt file (ie. run the command several times and if the same file is listed or anything that is listed appears odd (odd as in "oh, that corrupt file from last week") you might be able to solve your Spotlight trouble)

problems with indexing files could be anything from permissions to an excluded directory path

i am jack's amusing sig file

[ Reply to This | # ]

additional info that might help
Authored by: jaysoffian on Jun 15, '05 01:51:26PM
And perhaps a "better" way to do this is:

lsof -c mdimport -a ~
Although I admit half the time I can't remember lsof's options either (and its man page is awful), so I often resort to grep as well. But in this case, it only took a moment to find the correct options and if you're going to share a hint with others, it's worth the extra effort, don't you think? :-)

[ Reply to This | # ]
additional info that might help
Authored by: adrianm on Jun 16, '05 03:36:23AM
That doesn't completely work.

That is saying the command must be mdimport AND it must be your home directory - but not the contents.

You probably want this:

lsof -c mdimport -a +D ~
Which matches the contents of the home directory, but that, as the man page says is very slow, so maybe a compromise is order:

lsof -c mdimport | grep /Users/yourusername
Maybe you should have spent a bit more time reading the lsof man page :-)

[ Reply to This | # ]
Fantastic hint, thanks a million!
Authored by: PopMcGee on Jun 16, '05 05:23:38AM

I had the same problem, here, too and this one fixed it. One of the best 10.4 Hits thus far, thanks! :-)

[ Reply to This | # ]
Fantastic hint, thanks a million!
Authored by: allanBook on Jun 17, '05 01:29:08PM

I must agree, this hint rocks!!

My Spotlight is running faster. Thanks for sharing!

"Mr. Simpson, this is the most blatant case of fraudulent advertising since my suit against the film The NeverEnding Story." -Lionel Hutz (of Simpsons fame)

[ Reply to This | # ]
10.4: A way to check on a Spotlight indexing problem
Authored by: bozoface on Sep 13, '05 12:32:21AM

Lsof is really useful, did not know about it previously.

I had "mds" running seemingly continuously (had been running for half a day
at least), "top" showed it usually using 50% cpu, though mdimport was
usually not listed in the "top".

I tried this hint and found that the only file of mine
that mdimport had open was a .DS_Store file. Checked back 10 minutes later
and *the same* .DS_Store file is still the only open file of mine
(a bunch of library files that mdimport uses were open of course).

Is this (indexing a .DS_Store for minutes or hours) normal?

I deleted that .DS_Store, did a kill -HUP on mds, and a few minutes later it got stuck on a different .DS_Store file.

I deleted that one too, and now mds is no longer in the top, and
lsof | | grep mdimport no longer shows it hanging(?) on a .DS_Store.
Back to normal, evidently.

But I fear for what Spotlight must be doing to "regular" non-power users
out there...

I deleted that one

[ Reply to This | # ]
Authored by: bozoface on Sep 14, '05 07:28:48PM

My mdimport appears to be perpetually stuck on .DS_Store files, e.g.

mdimport 5882 me 7r VREG 14,2 21508 1354444 /Users/me/Devl/Java/L/GL/.DS_Store

If I delete this .DS_Store, it will find another one and stick there.

But in other respects spotlight seems to be working, though maybe a bit slowly.
"Touch foo/mdls foo" shows the newly created file for example.

So is the earlier statement that

'if "lsof|grep mdimport" shows it indexing a file for a long period, it indicates
something wrong with that file'

really correct? I believe .DS_Store contains some finder options for the
particular folder, and the finder view of that folder does not seem to have
any issues, so I don't have reason to believe that the .DS_Store is corrupted.

[ Reply to This | # ]
Authored by: Andrew Fletcher on Nov 03, '06 05:56:26AM

I tried all of the hints above but they didn't help. I suspect mds was sticking on a file in the system frameworks directory. (The "grep /Users/`whoami` hides these.)

So I took the simple sledgehammer approach. I shutdown the system and rebooted. Problem solved!

[ Reply to This | # ]