4

On Snow Leopard, the locate database is updated once a week by a launchd job, /System/Library/LaunchDaemons/com.apple.locate.plist. I'd like to make the updater run daily, but AFAIK it's considered very bad form to edit anything in /System.

What's the best way to change its StartCalendarInterval so it runs once a day?

2 Answers 2

6

The way I understand it, that System folder launchd job does nothing but execute /usr/libexec/locate.updatedb itself.

So simply create your own launchd job executing /usr/libexec/locate.updatedb that runs once a day.

As a sidenote, here's a Super User answer which recommends using mdfind -name <filename> instead of locate so that you can use the Spotlight database which is continually updated.

And this Ask Different answer has more info on creating launchd jobs if you need more help with that.

2
  • +1 for creating a custom launchd job. iCal could schedule it - but that's an extra level of abstraction. Lingon is awesome if you don't like writing plist files by hand. itunes.apple.com/us/app/lingon/id411211026?mt=12
    – bmike
    Commented Jul 29, 2011 at 19:23
  • @bmike Thanks for the Lingon link. I had a vague memory of that no longer being developed, nice to see the developer is now selling it on the App Store.
    – ghoppe
    Commented Jul 29, 2011 at 19:26
0

The problem with 'locate' and with Spotlight is that it doesn't search every file. It used to be possible to work-around this by updating the updatedb as root, which would warn you that was a potential security hole (i.e. anyone with read access to the database could get a list of every file in any user's $HOME) but since most Mac users are the only user on their computers, that was not a huge concern.

I finally got so fed up that I wrote my own script which will:

  • make a plain-text index of every file, link, and directory
  • search that index using egrep
  • offer to restrict searches to $HOME or the current directory if certain arguments are given
  • if nothing is found in the index, offer to update the index, or search with mdfind

You can download the script here [Dropbox link]. It should be fairly easy to understand how it works just by reading through it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .