Solved

Updatedb on demand

Posted on 2006-06-23
5
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

717 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