Solved

Updatedb on demand

Posted on 2006-06-23
5
264 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

749 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