Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
    
+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 Jul 29 '11 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 Jul 29 '11 at 19:26
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.