I have set up a separate mlocate database to index a custom directory, it is updated by a cron task, but for some reason it does not index files created since the fist time the database was created. The indexed directory is located on a cifs mount, but I have removed cifs from PRUNEFS in /etc/updatedb.conf

Here is the command that runs hourly:

/usr/bin/updatedb -l0 -U /datadrive/data -o /tmp/locate.db

If I remove /tmp/locate.db and run the updatedb command then all the files are indexed properly. If I run it again then files newer than the original /tmp/locate.db are not indexed.

This runs on a Centos 7 VM in Azure and the cifs mount is an Azure Files share. It's mounted in /etc/fstab as follows:

//my_storage.file.core.windows.net/my_files /datadrive cifs vers=3.0,username=my_username,password=my_password,dir_mode=0777,file_mode=0777 0 0

So the question is - how do I make it index new files?


You need update your database firstly by using updatedb. You could modify your script like below:

/usr/bin/updatedb; /usr/bin/updatedb -l0 -U /home/shui/data -o /tmp/locate.db

I test in my lab, it works for me.

[root@shui tmp]# ls -alt locate.db
-rw-r-----. 1 root slocate 164858 Apr 27 03:58 locate.db
[root@shui tmp]# updatedb 
[root@shui tmp]# updatedb -l0 -U /home/shui/data -o /tmp/locate.db
[root@shui tmp]# ls -alt locate.db
-rw-r--r--. 1 root root 159136 Apr 27 04:07 locate.db
  • It doesn't solve my problem. – exfizik Apr 27 '17 at 19:52
  • It works for me. The locate.db size does not change? – Shui shengbao Apr 28 '17 at 0:59
  • It doesn't. Is your /home/shui/data on a cifs share? I believe that's my problem. – exfizik Apr 28 '17 at 20:20
  • Yes, /home/shui on a Azure file Share. It is a cifs share. – Shui shengbao May 1 '17 at 7:00
  • If I remove /tmp/locate.db before indexing then it finds all the files. – exfizik May 1 '17 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.