Boyd

Q: How to retain the locate /var/db/locate.database for removable external drive

I just ran sudo /usr/libexec/locate.updatedb with two external drives mounted.  I think when the command is next run by the weekly system update, and the drives are not mounted, then the data for those drives will be deleted.  I suppose I could copy /var/db/locate.database to a backup file, and then use the locate -d option to search for a file.  But is there a better way to handle this?

 

Maybe I should be using mdfind and mdutil to handle this, but I haven't understood about external drives for that either.

 

Thanks for helping.

 

Boyd

MacBook Pro with Retina display, OS X Yosemite (10.10.5)

Posted on Jun 22, 2016 6:35 PM

Close

Q: How to retain the locate /var/db/locate.database for removable external drive

  • All replies
  • Helpful answers

  • by Linc Davis,Helpful

    Linc Davis Linc Davis Jun 25, 2016 11:04 AM in response to Boyd
    Level 10 (207,926 points)
    Applications
    Jun 25, 2016 11:04 AM in response to Boyd

    But is there a better way to handle this?

    Yes. Use a disk-cataloging app. I'm sure you could find several in a web search. I don't have a specific recommendation.

  • by Boyd,

    Boyd Boyd Jun 25, 2016 10:38 AM in response to Linc Davis
    Level 2 (252 points)
    Mac OS X
    Jun 25, 2016 10:38 AM in response to Linc Davis

    So are there external apps that are better than the locate command or mdfind?  They are both databases.  My question has to do with how to retain the information for external drives when they are not on-line.  I have solved it for locate by saving /var/db/locate.database in my home folder and then use locate -d ~/locate.database option.  But then I have to periodically remember to run the sudo /usr/libexec/locate.updatedb when I have the external drives mounted if there have been significant changes that make the old database out-of-date.

  • by Mark Jalbert,

    Mark Jalbert Mark Jalbert Jun 25, 2016 11:31 AM in response to Boyd
    Level 5 (4,649 points)
    Jun 25, 2016 11:31 AM in response to Boyd

    Have you tried mdfind? It is a perfect fit for your goal.

  • by Boyd,

    Boyd Boyd Jun 25, 2016 4:44 PM in response to Mark Jalbert
    Level 2 (252 points)
    Mac OS X
    Jun 25, 2016 4:44 PM in response to Mark Jalbert

    Yes, and as I said before, it doesn't take care of off-line drives.