I am looking for a bash set of commands that will enable me to schedule the execution of /usr/libexec/locate.updatedb once every day.

Please respond only with a set of command line commands, because I want to include this in a "setup" script (in order to be able to reuse it when I go to another machine).

  • Or use the deprecated cron. – user588 May 26 '11 at 17:55
  • 1
    May I ask why you're using slocate instead of Spotlight? (At the command line: mdfind) – Jason Salaz May 26 '11 at 20:41
  • Just because it's the same an on other Unixes. – sorin May 26 '11 at 22:29
  • Depending on the OSX version, it should be rebuilt weekly. Look in /etc/periodic/weekly. You should find (on 10.5.8) 310.weekly. This rebuilds the locate database. – user14537 Dec 4 '11 at 15:22

After additional (re)search I found an easy solution:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

This is also persistent, so it will run updatedb daily.

| improve this answer | |
  • 4
    This only runs locate.updatedb weekly (every saturday morning at 3:15am). If you want it to run daily, remove <key>Weekday</key> <integer>6</integer> from the StartCalendarInterval dictionary in that plist file (then unload and reload it). – Gordon Davisson May 27 '11 at 0:34
  • Isn't there a way to run this so it is actually synced. Meaning if I delete then things get removed. Also if add, things get added. – mmm Jul 30 '19 at 19:34

You must log in to answer this question.

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