Locate DB

What is the "official" proper way to update the locate DB? If you run locate.updatedb as root, it scolds you to not run it as root. Running it as a user yields:

Code:
/usr/libexec/locate.updatedb: cannot create /var/db/locate.database: Permission denied
 
Even easier: Go into /etc/periodic.conf.local, and make sure weekly_locate_enable is set to true. Then it will automatically get updated once a week. I have actually a created a new entry in periodic/daily/320.locate, which is simply a copy of the weekly one, and disabled the weekly one; like that my locate is never older than a day.
 
The point here is that I need to update is manually; like when I mount another disk and want to index what's on the disk. Or when I add some stuff to a system and want to update locate right away
 
If you want to manually run the database update once: /usr/libexec/locate.updatedb. Read the man page for locate.updatedb first, and look in /etc/periodic/.../320.locate, which will show you examples of the command line arguments.
 
If you just want to update manually, you can also just run the periodic scripts manually:
# /etc/periodic/weekly/310.locate
 
Grrrrr.
If you want to manually run the database update once: /usr/libexec/locate.updatedb. Read the man page for locate.updatedb first, and look in /etc/periodic/.../320.locate, which will show you examples of the command line arguments.
The OP points out the problem with running locate.updatedb; regular users don't have permission to create the db because its owned by nobody so only root and nobody can update it.
 
Oops, sorry, missed that completely. You can not run it is a regular user, that's correct. You can run it as root, but you will get a warning, and the warning makes sense. You can run it as user nobody (example how to do it is in the 310.locate script, not 320 as I wrote, that was a typo).
 
Back
Top