locate command: on what basis, newly added files/folder will add to mlocate
Hi,
What is the time interval to update newly added files/folders to mlocate.db? I cannot execute "sudo udpatedb". why because, it needs authentication for current user. I have added folder on ubuntu desktop. I waited for 30+ mins. Still, locate didn't list newly added folder. what is the secret behind this? Thanks. |
If it's your machine, enter your password. Else you'll have to wait until (probably) cron runs updatedb.
|
I am running this command through programmatically. I am using locate command to search for folder on user machine. While testing, added folder on desktop, but not listed same folder when I search through locate command. So, my question is, on what basis, mlocate.db gets updated? Any time interval (like for every x mins), for every login, or for every restart? what is the logic behind mlocate database update?
|
What part of the following was unclear ?.
Quote:
|
You are correct. mlocate scheduled for every 6 hours, I checked with script which is available on stackoverflow. Do you have any idea how to change schedule?
I logged in as root, cd /etc and then executed crontab -l command. I am missing something so it's not listing cron jobs. |
changing config for cron needs root also. You seem to have several treads trying to solve the same problem. I think you really are stuck using find to find the files you want, when you want them.
|
@gnashley, I want to find folder in home directory without iterating file system. So, I chosen "locate" which is very fast and relies on mlocate database. But, as per my understandings, mlocate updates for every 6 hours. Now, I want to change the cron job scheduler to 2 mins. I want to edit mlocate cron. How to list the crons & edit them?
|
Try these commands:
man 1 crontab man 5 crontab |
Quote:
|
Thank you rknichols.
|
Unless you have root rights, you cannot change the frequency of database updates run by cron.
|
If you are just concerned about your home directory, consider running updatedb with overriding "--prune*" options to restrict its scan and a "-o" (--output) option to create a custom database. That would run a lot faster than the overall mlocate job, but you would need to run locate with the "-d" (--database) option to use your database. You could even trigger that scan from a program using the inotify(7) package that monitors the directories of interest.
|
Just for your information...
Typically updatedb runs once a day from /etc/cron.daily and you can find the start time by examining your /etc/crontab file. |
Quote:
Quote:
|
Quote:
|
All times are GMT -5. The time now is 04:24 PM. |