You are not logged in.
Pages: 1
how do i configure cron to update slocate database every day.
Offline
By default slocate installs a script in /etc/cron.daily. Scripts in this directory get run every day, shortly after midnight. Thus, the only step you have to perform is to make sure that crond is working (i.e. placed in your /etc/rc.conf). Incidentally, I suggest installing mlocate instead of slocate - it recreates a db faster.
Offline
In my crond daily folder is is no file for slocate but there is a file for locate as updatedb:
#!/bin/sh
# Update the "locate" database
if [ -x /usr/bin/updatedb ]; then
if [ -f /etc/updatedb.conf ]; then
/usr/bin/nice /usr/bin/updatedb
else
/usr/bin/nice /usr/bin/updatedb -f proc
fi
fiOffline
That's the file lucke is referring to - it is installed by the slocate package. Check the package file list if you want to confirm this.
Offline
Note that if you are using normal cron and your machine doesn't run all the time, the job might not get run. Cron assumes your machine is always running, so if a job is scheduled for 3 a.m. daily but your computer is always off at 3 a.m., the job will never run. For machines that are not always on, you may want to use either anacron or fcron. These don't assume the machine is always running, so if they detect a job has been missed because the machine was off, the job will run.
Offline
Ok Thanks. I have replaced dcron with fcron, but now how should i set fcron to upate slocate every 1 or 2 hour.
Last edited by jaideep_jdof (2007-10-22 14:22:06)
Offline
My memory is a bit hazy and I don't have fcron installed right now, but I believe you can do something like the following:
1. Log in as root.
2. run fcrontab -e.
3. Add a line like
@ 2h /etc/cron.daily/updatedb4. Save the file.
That should do the trick. Perhaps I will install it and check it out. You might try man fcrontab and man 5 fcrontab for more information.
Good luck.
Offline
Also, if you intend to run updatedb that often, you are probably better off with mlocate instead of slocate.
1000
Offline
Pages: 1