- Script to check files in adirectory older than X hours
- Posted by raghav on April 16th, 2008
hi guys ,
I need to develop a script to check for all files in a directory that
are older than X hours ,
I have tried with atime ,mtime & some of the switches using the ls
command .
please suggest me some tips .
thanks your help is appreciated .
- Posted by Barry Margolin on April 16th, 2008
In article
<17de4b21-91e5-4751-b4ec-60950a5b977b@m71g2000hse.googlegroups.com>,
raghav <raghav.belurkar@gmail.com> wrote:
Use GNU find with the -mmin option:
find <dir> -type f -mmin +<X*60>
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
- Posted by Doug Freyburger on April 17th, 2008
raghav <raghav.belur...@gmail.com> wrote:
I looked at "touch -t" on the first system I accessed (HPUX
today) and it is able to create a file with an mtime specified
to the nearest second.
Get the current time into a variable. Do some time arithmatic
and make a string that has the time X hours ago to the
nearest second. "touch -t $thentime /tmp/anchor.$$" to have
an anchor file in place. Then do
find $yourdir -type f -older /tmp/anchor.$$ -print | your_processing
End with rm /tmp/anchor.$$ to clean up.