cancel
Showing results for 
Search instead for 
Did you mean: 

To find files 5 hour older

 
Narendra Uttekar
Regular Advisor

To find files 5 hour older

Hi,
I want to find the files generated by oralce as dbf 5 hours older and delete those files.
find /oracle/TCP/saparch/TCParch -name file "*.dbf" -mtime +0 -exec rm '{}' . \; will find 24 hrs older file. But i want to have 5 hours older
9 REPLIES
Jeeshan
Honored Contributor

Re: To find files 5 hour older

this sample perl script will tell you the last 1 hour which files are created

#perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -M _ <= 1/24},@ARGV)' /path


modify as per your requirement.
a warrior never quits
Dennis Handly
Acclaimed Contributor

Re: To find files 5 hour older

You can also create a reference file with touch(1) then use the -newer option in find(1):
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1254376
James R. Ferguson
Acclaimed Contributor

Re: To find files 5 hour older

Hi:

Perl will do this. You want files that are "older" (less recently modified) than 5-hours ago and only those that have a ".dbf'" extension, so you need:

# perl -MFile::Find -le 'find(sub{unlink $File::Find::name if -f $_ && -M _ >= 5/24 && $_=~/.+\.dbf/},@ARGV)' /oracle/TCP/saparch/TCParch

Notice that Ahsan's post printed and didn't remove filenames and returned files modified during the last (1) hour --- a cut and paste from another post that didn't solve your problem.

Regards!

...JRF...
Fredrik.eriksson
Valued Contributor

Re: To find files 5 hour older

as said above, find will do this for you :)

$ touch -t 200812150000 /tmp/ref1.tmp
$ touch -t 200812150500 /tmp/ref2.tmp
$ find ./ -type f -newer /tmp/ref1.tmp ! -newer /tmp/ref2.tmp -iname \*.dbf -exec rm {} \;

Best regards
Fredrik Eriksson
rmueller58
Valued Contributor

Re: To find files 5 hour older

The standard HP/UX find -mtime 0 is within the last 24 hours, if you can use the "GNU" find you can use the -mmin 300 (for 5 hours) for 24+5 with the GNU find you would use
-mmin 1740

rmueller58
Valued Contributor

Re: To find files 5 hour older

your command:
find /oracle/TCP/saparch/TCParch -name file "*.dbf" -mtime +0 -exec rm '{}' . \; will find 24 hrs older file. But i want to have 5 hours older

GNU command
5 Hours
find /oracle/TCP/saparch/TCParch -type f -name "*.dbf" -mmin 300 -exec rm '{}' .\;

29 Hours
find /oracle/TCP/saparch/TCParch -type f -name "*.dbf" -mmin 1740 -exec rm '{}' .\;

http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.4.0/

rmueller58
Valued Contributor

Re: To find files 5 hour older

rmueller58
Valued Contributor

Re: To find files 5 hour older

I mean "James F"
Narendra Uttekar
Regular Advisor

Re: To find files 5 hour older

Thanks for the solution.