Solved

Updatedb on demand

Posted on 2006-06-23
5
261 Views
Last Modified: 2010-04-20
it's possible, so the system database is uptodate ever when new files is created or deleted?
0
Comment
Question by:rubentrancoso
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:pjedmond
ID: 16968433
Well you could replace the rm command with an script that first runs the rm command, and then runs updatedb on the path concerned. However, there aer numberous otherways to delete files, so this approach isn't exactly doing to be 100% perfect.

With respect to making new files, there are so many programs that make files, that trying to use a similar approach wouldn't really be possible:(

I guess that the best bet for you would be to run updatedb as a cron job everynight (or at a quiet time) to ensure that the data was reasonably current?

crontab -e

Then add the line(or similar):

45 23 * * * /path/to/updatedb

(   (()
(`-' _\
 ''  ''
0
 
LVL 16

Expert Comment

by:xDamox
ID: 16971002
Hi,

In your cron.daily directory located in the /etc you might have the following file:

mlocate.cron

This file runs updatedb daily.
0
 

Author Comment

by:rubentrancoso
ID: 16971120
ok, but It's not what I was asking. I already know cron. My questin is regard some way to monitor all files and update on demand.
0
 
LVL 16

Expert Comment

by:xDamox
ID: 16971186
The only method I can think of is once you have deleted a file that you the user run the updatedb command
0
 
LVL 22

Accepted Solution

by:
pjedmond earned 500 total points
ID: 16971519
As I alluded, you can either create a script called rm and rename rm to something else that gets called, or you can have your own special updating rm say surm:

-----------8X----------------------
#!/bin/bash

UDP=${1%/*}

echo $UDP

if [ "$UDP" eq "$1" ]
then
  rm $1
  updatedb -U .      # If no directory, update the cwd
else
  rm $1
  updatedb -U $UDP   # Just update the directory adffected
fi
-----------8X----------------------

Which does the updating for you. For creating files, there are so may ways that something like that can be done, that you'd have to patch all sorts of things, or create wrappers around them...and then start on the process of dealling with applications. Of course you could start 'patching' the glibc, but then when people (or you) want performance creating and deleteing files, you will get a fairly severe performance degradation.

 (   (()
(`-' _\
 ''  ''
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now