For the benefit of Windows users, I should explain that Spotlight is the Apple OS X indexing system. It sounds really neat: clever search, automatic creation of “smart folders” containing things like files created today, the possibility of creating custom-built smart folders, automatic (but customisable) search across a whole range of things. It was intended to be another example of Apple’s winning software strategy: reliability coupled with clever defaults which suit 99% of users.
Unfortunately, I often fall into the 1% who do not find the defaults quite meet my needs, but I have to admit that quite often the defaults are good enough, and it is usually not that difficult to figure out how to modify the defaults. Apple seems to have a clear policy on that: it gives you no help whatever. If you do not want “Time Machine” (a really neat automatic backup system) to give you hourly backups, then tough. But usually the defaults are neatly squirrelled away in text files and there seem to be plenty of geeks on the forums eager to point you to them. I guess if I had more time to fiddle, I could even figure them out for myself.
Some years ago, I decided that Spotlight was a total dog. In common with many others on the forums I found the damned thing spent too much of my CPU time indexing. Disabling it proved fairly tricky. There were umpteen suggestions on the forums, some better informed than others. Sadly OS X, or to be more precise all the stuff that Apple has heaped on top of the basic Unix, is showing clear signs of legacy software. There is rarely one text file relevant to a particular setting. Sometimes you have four or five, which, of course, the operating system consults in a particular order, so you sometimes have to fiddle with all the wretched things to get the behaviour you want. And if you are not extremely disciplined it is easy to leave hard-to-fix booby traps for later (which is no doubt why Apple do nothing to encourage such tinkering).
Anyway, I disabled Spotlight. I occasionally mused that it was a pity I could not have retained that “recent files” smart folder, but disabling was a big step forward in terms of removing aggravation.
Then a couple of years ago, I began to run into what I later diagnosed as hard disk failures. There were endless delays while the disk was (presumably) coping with bad sectors on the disk. I fixed that by migrating to an external drive (another bizarrely complicated process – there turned out to be subtleties about getting an iMac to boot of an external drive). Things improved for a year or so, but then the delays came back. I finally grasped that PCs are no longer designed to work for decades, they are designed to fall apart after 5 years or so, so I bought a new iMac. I love it, but after I while I began to wonder whether Spotlight might work better with my new faster processor.
Re-enabling the wretched thing has not proved straightforward. The only record I could find of how I had finally disabled it turned out to be a text file:
Trying the launchctl load command just gave an error message “Nothing to load”. A little googling showed that the command for Spotlight is mdutil. So I did the basic Unix trick of typing “man mdutil” onto the command line. It turned out that “mdutil -s” gives the status. That returned that Spotlight was indeed disabled. So I tried “mdutil -a -i on ” which is supposed to enable Spotlight on all drives. That returned:
Metadata.framework [Error]: mdsCopyStorePaths failed: (268435459) (ipc/send) invalid destination port
Spotlight server is disabled.
Of course, you can see how dumb I was being: that launchctl unload -w command had put Spotlight beyond the reach of turning on or off. So first I had to undo that. Indeed, the author of the image text above (gulp! was it me?) has put the two turn-on commands in the wrong order (as any mathematician ought to have grasped instantly – you would not expect them to commute).
So after a quick launchctl load -w followed by an mdutil -a -i on, I got this when I clicked Spotlight at the top right of the screen:
29 hours! This is not promising … Now 1pm, we will see.
Update. Just 8 minutes later the estimate is down to 9 hours. 🙂 Of course, that bug (hopeless time estimates) is slightly tricky to fix, because you would have to add file sizes rather than just count the number of files. There can be tens of thousands of files or more, so to make that work, you need some slightly complicated mix of adding sizes for large files and counting the numbers of small ones. But it would be eminently doable …
Update. 7 minutes later it is showing 3 hours to go. Curiously, the blue line has only about doubled in length, so that visual indicator suggests the process is only 15% complete. Hmmm. Maybe it is more reliable than the text indicator – that implies about 80 mins to go.