Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

10.5: Get locate to index the Time Machine drive UNIX
I'm a big fan of locate, even in this day and age of Spotlight; it's a super-fast way to find things in Terminal (with the downside that it needs updates to remain current, as it's a static index of file names). By default in 10.5, locate won't find files on Time Machine drives -- this is probably a good thing, as it greatly increases both the size of the database and the number of returned matches.

However, I was working on a project, and I wanted this information in locate. The solution is pretty simple: you need to edit /usr/libexec/locate.updatedb (with sudo). Look for this line:
: ${PRUNEPATHS:="/tmp /var/tmp */Backups.backupdb"} # unwanted directories
Edit it to remove the */Backups.backupdb bit, then save your changes, quit the editor, and update the database (sudo ./locate.updatedb from that same directory).
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[5,405 views]  

10.5: Get locate to index the Time Machine drive | 8 comments | Create New Account
Click here to return to the '10.5: Get locate to index the Time Machine drive' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
10.5: Get locate to index the Time Machine drive
Authored by: ecbtln on Fri, Nov 16 2007 at 2:52PM PST
what is the advantage of using locate over mdfind?

[ Reply to This | # ]
10.5: Get locate to index the Time Machine drive
Authored by: robg on Fri, Nov 16 2007 at 3:16PM PST
When I've tried it, mdfind didn't seem to match just filenames. For instance, mdfind foo found this:

/Applications/iWork '08/User Guides/Pages User Guide.pdf

I don't see 'foo' anywhere in there. locate foo, on the other hand, returns only filenames, and it's quite fast.

-rob.

[ Reply to This | # ]
10.5: Get locate to index the Time Machine drive
Authored by: PatrickS on Fri, Nov 16 2007 at 3:38PM PST
Try mdfind 'kMDItemFSName == foo' (or mdimport -X 2>&1 | less for a list of all search attributes).

locate is significantly faster though...

[ Reply to This | # ]

10.5: Get locate to index the Time Machine drive
Authored by: baltwo on Fri, Nov 16 2007 at 7:48PM PST
Super fast, since it only searches for patterns in paths.

[ Reply to This | # ]
10.5: Get locate to index the Time Machine drive
Authored by: vasi on Sat, Nov 17 2007 at 7:16AM PST
The file /usr/libexec/locate.updatedb belongs to the system and may be overwritten by any future system update. Thankfully, Apple finally provided us in Leopard with configuration files for the periodic maintenance scripts. In the locate configuration file /etc/locate.rc , you can uncomment the line settings PRUNEPATHS and it should have the same effect as this script.

While we're on the topic, should you want to turn off the locate update script entirely, you can create /etc/periodic.conf and add this line:

weekly_locate_enable="NO"

Other options for your periodic.conf can be found in /usr/defaults/periodic.conf.

[ Reply to This | # ]
10.5: Get locate to index the Time Machine drive
Authored by: bgg on Sun, Nov 18 2007 at 4:09PM PST
Rather than edit the system file /usr/libexec/locate.updatedb, you can adjust the paths used by editing the file /etc/locate.rc.

This is read by locate.updatedb when it starts up to set custom paths and so on.

Editing system files is fraught because if they are updated, you are liable to lose your changes or you'll have to manually merge in your customisations to the updated file.

[ Reply to This | # ]

Problem in downloading ZIP Files
Authored by: Vjsaharan on Mon, Nov 19 2007 at 7:16AM PST
Some of my MAC clients are having problem in downloading files that are having ZIP extension. We need to manually rename the file as .ZIP to open the folder.
Kindly tell me how to resolve this issue

[ Reply to This | # ]
10.5: Get locate to index the Time Machine drive
Authored by: david-bo on Tue, Jul 1 2008 at 4:55AM PDT
I would like to see something (launchd?) that told the locate update script about changes of file names and paths everytime they happened so that the locate db could be updated dynamically.

[ Reply to This | # ]