1752756 Members
4996 Online
108789 Solutions
New Discussion юеВ

Directory monitoring

 
Sebastien Masson
Valued Contributor

Directory monitoring

Hi all,

Someone know a tool or a script that can monitor a specific directory for any new file creation. I want to mirror my Oracle redo log file on an external FTP server but I don't want to sync the directory each hour... I want to copy the file when they appear in the oraarch...

Thanks
5 REPLIES 5
Darrell Allen
Honored Contributor

Re: Directory monitoring

Hi,

I haven't used it but rdist sounds like it may do that. It is available from the Software Porting and Archive Centres. One is:
http://hpux.cs.utah.edu/

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Steve Steel
Honored Contributor

Re: Directory monitoring

Hi

touch a file ex /tmp/checkdir before you start
with an old date

Then something like this running every hour

test=/tmp/checkdir
work=/tmp/checkwork
dir=/home/steves/tmp
find $dir -type f -newer $test > $work
touch $test
typeset -i found=$(cat $work|wc -l)
if [ "$found" -gt "0" ]
then
cat $work|while read line
do
echo ftp $line to remote
done
fi
/bin/rm $work 2>/dev/null

If file are found newer than the checkfile you can ftp them or rcp them

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
harry d brown jr
Honored Contributor

Re: Directory monitoring

Sebastien,

You really want to do it when the file is closed, for this test I'd suggest getting "lsof" from:

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.61/

and writing a perl program monitor directory changes. It's important to make sure the file is no longer "inuse". Also with perl you can ftp directly from it.

live free or die
harry
Live Free or Die
Olivier LEGRAND
Frequent Advisor

Re: Directory monitoring

Hi,
Harry, to do that we can use the "fuser -u $filename" command. The perl language is not necessary.

Regards
Eric Ladner
Trusted Contributor

Re: Directory monitoring

Just a process check.

Oracle redo logs are created when the database is created and don't change on a daily basis (the contents change, the file doesn't)

If you really want to copy your redo logs somewhere, turn archivelog mode on and tell oracle where to put the archived redo logs when they are switched out.