I use the locate command in Terminal regularly. When does its database get updated? On other systems, I could run updatedb as root to force it to update.

Note: I know using mdfind to search with spotlight is another option


The locate database is updated by the following cronjob:


On Most Mac systems, Cron has been replaced by launchd, and you'll find that /etc/crontab doesn't exist. The schedule for this scheduled job is determined by launchd, and can be seen with one of the following commands:

% cat /System/Library/LaunchDaemons/com.apple.periodic-weekly.plist
    #### SNIP

Or, something a little more user friendly:

% open /System/Library/LaunchDaemons/com.apple.periodic-weekly.plist

launchd will then run the jobs specified in /etc/periodic/{daily,weekly,monthly}/*, using this schedule.

| improve this answer | |
  • 1
    tl;dr version: Saturdays at 3:15 AM local time. – Chealion Oct 6 '10 at 22:38
  • 1
    Or if the mac is sleeping at 3:15 AM Saturday morning, when it wakes. – bmike Jun 10 '11 at 0:02
  • Yet another way to see the contents of the plist: defaults read /System/Library/LaunchDaemons/com.apple.periodic-weekly – Harald Hanche-Olsen Jun 10 '11 at 16:26

sudo periodic weekly is the easiest way to kick it off the weekly script which will call the normal rebuild of the locate database.

As noted launchd will start this script Saturdays at 03:15 AM if the mac is running. If the mac is sleeping at that time, it will run when the mac wakes. It won't run if the mac is powered off at the magic moment.

| improve this answer | |

From the locate manpage:

 /var/db/locate.database          locate database
 /usr/libexec/locate.updatedb     Script to update the locate database
 /etc/periodic/weekly/310.locate  Script that starts the database rebuild

By default, the database is rebuilt weekly through launchd. You can run locate.updatedb manually to do the update.

| improve this answer | |
  • 2
    On most Mac systems, cron is replaced by launchd. There is no /etc/crontab by default, for example. That was moved to launchd. – Stefan Lasiewski Oct 6 '10 at 17:33
  • @Stefan - Your right. I forgot about that change, which Apple did in Tiger. – KeithB Oct 6 '10 at 18:13

You must log in to answer this question.

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