You are not logged in.

#1 2007-10-21 19:42:41

jaideep_jdof
Member
From: Delhi, India
Registered: 2006-06-05
Posts: 311

slocate and crond

how do i configure cron to update slocate database every day.

Offline

#2 2007-10-21 20:06:42

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: slocate and crond

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

#3 2007-10-22 06:42:46

jaideep_jdof
Member
From: Delhi, India
Registered: 2006-06-05
Posts: 311

Re: slocate and crond

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
fi

Offline

#4 2007-10-22 06:57:57

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: slocate and crond

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

#5 2007-10-22 07:34:57

jbromley
Member
From: Pasadena, CA
Registered: 2007-02-04
Posts: 268

Re: slocate and crond

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

#6 2007-10-22 08:14:33

jaideep_jdof
Member
From: Delhi, India
Registered: 2006-06-05
Posts: 311

Re: slocate and crond

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

#7 2007-10-30 04:52:14

jbromley
Member
From: Pasadena, CA
Registered: 2007-02-04
Posts: 268

Re: slocate and crond

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/updatedb

4. 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

#8 2007-10-30 06:58:54

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: slocate and crond

Also, if you intend to run updatedb that often, you are probably better off with mlocate instead of slocate.


1000

Offline

Board footer

Powered by FluxBB