Quickly search index of all files on nas?

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Perhaps my system is broken, a bug in my old 9.2.1.6 install, a USB write issue or some such but I recall having trouble, I'll have a fiddle now.
As for the users fussing about specs, moving to minimum 8gb / 64bit is fine with me - although knowing you, you'll push for 16gb minimum sooner or later!


EDIT: It could be as simple as me being accustomed to the command being "updatedb" under linux systems, rather than locate.updatedb
Regardless, I do know that, at least ONCE I managed to do a fully successful updatedb (which I'm doing right now as I type this) yet the locate command didn't work or didn't find files I knew existed :/
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Regardless, I do know that, at least ONCE I managed to do a fully successful updatedb (which I'm doing right now as I type this) yet the locate command didn't work or didn't find files I knew existed :/

If that is the case then you may need to consider:

-The locate database doesn't auto-update. So a new file created after the last scan won't show up in a locate search.
-If you run the locate.updatedb as "root" you will only index the areas that are accessible to "root". Oh, and now things get ugly because if you are doing CIFS shares with weird permissions, the root user may not have access. :P
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I did it as root, created a cron job for it. Is it possible that the actual DB file itself is lost on a reboot? Perhaps that's why I had issues?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Well, it goes to /var/db I think, and that used to be a RAM drive (pre-9.3). Now it's the .system dataset on 9.3. But if you had no DB file you'd try to do a locate and it would throw an error that the database was too short (0 bytes).
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I tried creating a cron job for this and I keep getting "./usr/libexec/locate.updated: not found"
I've also tried
"/usr/libexec/locate.updated" (no full stop) I'm stuffed if I know what I'm doing wrong - it's running as root?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Here's what I wrote....

# /usr/libexec/locate.updatedb

Here's what you did...

# /usr/libexec/locate.updated

Notice a difference? You have a typo....
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Oh man...... Thanks dude.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
You have 358 posts and you made a typo like that and didn't catch that!? Turn in your geek card. ;)
 
Joined
Sep 9, 2016
Messages
8
I know this is an old thread, but since I ran across the problem with updatedb writing, obviously, the locate.database in /var/db which is deleted at reboot, and which is also presumably on a fragile memory device, I have this suggestion:
make a copy of /usr/libexec/locate.updatedb in an area of your choice of the user area, edit it and replace target /var/db/locate.database to a file in that area and, optionally but not really, add as the last like add a command like:

ln -sf the_full_path_of_your_locate_database /var/db/locate.database

If you do not run locate.updatedb as root, this last command won't work, so I suggest that instead you put this command in the cron job (which must be run by root) .
This will make the database permanent across boots and make it effectively the database used by the locate command.
In the cron job to update the db, you will be calling your custom locate.updatedb script.
 
Last edited:

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I've ended up learning the find command or memorisinng it anyhow.

find . -name 'blah'

It takes some time but it works with certainty.
 
Top