Script to check files in adirectory older than X hours - Unix
This is a discussion on Script to check files in adirectory older than X hours - Unix ; 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 .
...
-
Script to check files in adirectory older than X hours
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 .
-
Re: Script to check files in adirectory older than X hours
In article
<17de4b21-91e5-4751-b4ec-60950a5b977b@m71g2000hse.googlegroups.com>,
raghav wrote:
> 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 .
Use GNU find with the -mmin option:
find -type f -mmin +
--
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 ***
-
Re: Script to check files in adirectory older than X hours
raghav wrote:
>
> 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 .
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.