1836428 Members
3899 Online
110100 Solutions
New Discussion

find + mtime + newer

 
SOLVED
Go to solution
Barbara Flynn_1
Frequent Advisor

find + mtime + newer

Hi

I am trying to write a script to gzip archive log files created today, I need it to run every 10 minutes as the database does a lot of processing.

I don't want to gzip the file that it is currently writing to, I have tried using variations of find but I can't get it to do exactly what I want.

find /archivelog -mtime 0 gives me all the files but I would to get all bar the most recent one.

Any ideas on a simple way of doing this??

Thanks in advance,
Barbara
6 REPLIES 6
Georg Tresselt
Honored Contributor

Re: find + mtime + newer

I assume the log files are all in the same directory. So, I would use a simpe ls -l instead of find.
http://www.tresselt.eu
Georg Tresselt
Honored Contributor

Re: find + mtime + newer

... and should they be not in the same directory, you probably could use ls -Rl
http://www.tresselt.eu
Hein van den Heuvel
Honored Contributor

Re: find + mtime + newer


Oracle archive logs have a simple numbering convention which you partly specify in the initXXX.ora file.

It should be trivial to remember the last file processed no? In a (shell/perl) loop generate the next file and stat it to check it to compare its mtime, ctime and atime?

How long does it take to write the archive logs? How about every time in the loop you 'touch' a marker file. Then find all files NOT newer than the marker and those are candidates.

hth,
Hein.


bhavin asokan
Honored Contributor
Solution

Re: find + mtime + newer

hi,

try the following
2004 ---year
12 ----month
13 -----date
10 & 11 hour
10 & 15 min
touch -t 200412131010 start
(it will create a file with time stamp 13/12/2004 and time 10.10am)

touch -t 200412131115 stop
(it will create a file with time stamp 13/12/2004 and time 11.15am)

then

#find /home/hpadm -newer start -a ! -newer stop

this will find the files created between 10.10 and 11.15

by script you can change the time stamp of start and stop files and can be used for finding files between that times.

regds,

Andreas Voss
Honored Contributor

Re: find + mtime + newer

Hi,

redo archive logs are written one by one,
that means only one file is actually written and that is the newest one.
To find all files without having the actual one you only have to list the dir ordered by last modfication time and skip the first one:

for file in $(ls -t | tail +2)
do
gzip $file
done

Regards
Barbara Flynn_1
Frequent Advisor

Re: find + mtime + newer

Thanks, the last two answers helped me a lot!