Wednesday, April 18, 2012

Updating the Locate database in FreeBSD (updatedb)

When I was running CentOS boxes if I needed to find a recently installed program or new file I would just run updatedb.  That however doesn't work as expected on FreeBSD (9.0 in my case).


When I first installed the machine I tried to run locate SOMETHING and got the error message locate: "database too small: /var/db/locate.database"


My first instinct was to run updatedb, which of course returns "updatedb: Command not found.".  It turns out there is a weekly cron job that will update the locate database, but if your server isn't on then (as is the case for me, since its a virtual machine on my local PC to toy around with) then you need to run the command manually. 


Just run the following script: "/etc/periodic/weekly/310.locate".  It may take a few minutes to run so just let it do its thing, or run it in a screen session.


By the way, I will most likely be posting a lot of FreeBSD tips and tricks in the coming months, as my new company runs mostly FreeBSD and Perl. 

2 comments:

Majdi Othman said...

Thanks. That was very helpful to me.

Anonymous said...

Thanks, helped me too.