Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,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 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[7,945 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 whoever 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 Nov 16, '07 02:52:02PM

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 Nov 16, '07 03:16:14PM

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 Nov 16, '07 03:38:09PM
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 Nov 16, '07 07:48:42PM

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 Nov 17, '07 07:16:13AM

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 Nov 18, '07 04:09:28PM
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 Nov 19, '07 07:16:09AM

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 Jul 01, '08 04:55:06AM

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 | # ]