files that has not been modified for more than 4 hours

files that has not been modified for more than 4 hours

Post by Shawn Ye » Tue, 16 May 2000 04:00:00



Hi all,

How can I list files that has not been modified for more than 4 hours in
a directory.

Thanks in advance!

Shawn

 
 
 

files that has not been modified for more than 4 hours

Post by S?ren Hol » Wed, 17 May 2000 04:00:00


find <dir> -mtime +4


Quote:> Hi all,

> How can I list files that has not been modified for more than 4 hours in
> a directory.

> Thanks in advance!

> Shawn


 
 
 

files that has not been modified for more than 4 hours

Post by Zoran Cutur » Wed, 17 May 2000 04:00:00



> find <dir> -mtime +4



> > Hi all,

> > How can I list files that has not been modified for more than 4 hours in
> > a directory.

> > Thanks in advance!

> > Shawn

I bet you're wrong! :-(

from finds man page:

          -mtime n
              File's data was last modified n*24 hours ago.

So n gets to be days!! not hours as the OP originally asked.

My GNU find version 4.1 supports a -mmin option that can check
for changes in between the last minutes!

          -mmin n
              File's data was last modified n minutes ago.

So 'find <dir> -type f -mmin 240 -print' will print out regular
files that where modified 240 minutes (I thought this where 4 hours:-))

If your find does not support -mmin it will most probably have the
-newer
option where you can check against the modification time of an other
file.

So a workaround is to create a file with mod time 4 hours ago and to use
find with -newer! Read man touch.

Hope this helps.
        Z

 
 
 

files that has not been modified for more than 4 hours

Post by S?ren Hol » Wed, 17 May 2000 04:00:00




> > find <dir> -mtime +4



> > > Hi all,

> > > How can I list files that has not been modified for more than 4 hours
in
> > > a directory.

> > > Thanks in advance!

> > > Shawn

> I bet you're wrong! :-(

> from finds man page:

>   -mtime n
>               File's data was last modified n*24 hours ago.

> So n gets to be days!! not hours as the OP originally asked.

> My GNU find version 4.1 supports a -mmin option that can check
> for changes in between the last minutes!

>           -mmin n
>               File's data was last modified n minutes ago.

> So 'find <dir> -type f -mmin 240 -print' will print out regular
> files that where modified 240 minutes (I thought this where 4 hours:-))

> If your find does not support -mmin it will most probably have the
> -newer
> option where you can check against the modification time of an other
> file.

> So a workaround is to create a file with mod time 4 hours ago and to use
> find with -newer! Read man touch.

> Hope this helps.
> Z

OOps
that did'nt come out right !! sorry

but
find <dir> -type f -mmin 240 -print
is'nt corret either. It finds file that are modified exactly 4 hous ago
use 'find <dir> -type f -mmin -240 -print' instead

 
 
 

files that has not been modified for more than 4 hours

Post by Zoran Cutur » Wed, 17 May 2000 04:00:00






> > > find <dir> -mtime +4



> > > > Hi all,

> > > > How can I list files that has not been modified for more than 4 hours
> in
> > > > a directory.

> > > > Thanks in advance!

> > > > Shawn

> > I bet you're wrong! :-(

> > from finds man page:

> >   -mtime n
> >               File's data was last modified n*24 hours ago.

> > So n gets to be days!! not hours as the OP originally asked.

> > My GNU find version 4.1 supports a -mmin option that can check
> > for changes in between the last minutes!

> >           -mmin n
> >               File's data was last modified n minutes ago.

> > So 'find <dir> -type f -mmin 240 -print' will print out regular
> > files that where modified 240 minutes (I thought this where 4 hours:-))

> > If your find does not support -mmin it will most probably have the
> > -newer
> > option where you can check against the modification time of an other
> > file.

> > So a workaround is to create a file with mod time 4 hours ago and to use
> > find with -newer! Read man touch.

> > Hope this helps.
> > Z

> OOps
> that did'nt come out right !! sorry

> but
> find <dir> -type f -mmin 240 -print
> is'nt corret either. It finds file that are modified exactly 4 hous ago
> use 'find <dir> -type f -mmin -240 -print' instead

douvble oops...!

never mind, but still we're both wrong, the man page turns out to be
right!:)

        Numeric arguments can be specified as

               +n     for greater than n,

               -n     for less than n,

               n      for exactly n.

So one will have to write:
find <dir> -type f -mmin +240 -print
to get all files that have not been modified in between the last four
hours!:-)
Yours would get the file that were modified in the past four hours.

        Z

--
LISP is worth learning for the profound enlightenment experience you
will have when you finally get it; that experience will make you a
better programmer for the rest of your days.         Eric S. Raymond
------------------------------------------------------------------------
   _/_/_/_/_/    _/_/_/_/ from:  Zoran Cutura,
          _/   _/      _/     IMH-Innovative Motorentechnik Prof. Huber,
        _/    _/          post:  DaimlerChrysler AG, EP/VRS, X910,
      _/     _/                  71059 Sindelfingen, Germany,
    _/      _/            phone: +497031 90-77855
  _/       _/       _/    mobil: +49171 4488407

       PGP fingerprint: F0 C3 30 F4 B3 7E 22 36  1C 51 B7 60 A9 BB 23 BE

 
 
 

files that has not been modified for more than 4 hours

Post by Michael Sternber » Wed, 17 May 2000 04:00:00



> How can I list files that has not been modified for more than 4 hours
> in a directory.

If you just need it "FYI", use "ls -t", plain simple.

Do I guess correctly you need this in the context of some packaging
operation?  Then you may want it semi-automatic:  manually touch(1) a file
4 hours back and use

        find . ! -newer /tmp/marker

If you don't want recursion, use a ksh loop with the -nt test operator:

        for i in *
        do
            [[ $i -nt /tmp/marker ]] && print $i
        done

Note that a bulletproof calculation of time differences (with date(1))
leads to a whole slew of portability problems, as frequently discussed
here.  If you want it bullet-proof and automatic, write it in perl.
S?ren's and Zoran's finally :-) converged recommendation of GNU find +mmin
is fine if you can rely on GNU being available.

Regards,
--
Michael Sternberg                        | Uni-GH Paderborn
http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
phone: +49-(0)5251-60-2329   fax: -3435  | 33098 Paderborn, Germany
"Who disturrrbs me at this time?"  << Zaphod Beeblebrox IV >>     <*>

 
 
 

files that has not been modified for more than 4 hours

Post by Shawn Ye » Wed, 17 May 2000 04:00:00


Is there a way to automatically 'touch' a file that is 4 hours back of current
time?  I think my question is how to create a time stamp that is 4 hours back?

Thank you for all the helps!  I am very grateful.

Shawn



> > How can I list files that has not been modified for more than 4 hours
> > in a directory.

> If you just need it "FYI", use "ls -t", plain simple.

> Do I guess correctly you need this in the context of some packaging
> operation?  Then you may want it semi-automatic:  manually touch(1) a file
> 4 hours back and use

>         find . ! -newer /tmp/marker

> If you don't want recursion, use a ksh loop with the -nt test operator:

>         for i in *
>         do
>             [[ $i -nt /tmp/marker ]] && print $i
>         done

> Note that a bulletproof calculation of time differences (with date(1))
> leads to a whole slew of portability problems, as frequently discussed
> here.  If you want it bullet-proof and automatic, write it in perl.
> S?ren's and Zoran's finally :-) converged recommendation of GNU find +mmin
> is fine if you can rely on GNU being available.

> Regards,
> --
> Michael Sternberg                        | Uni-GH Paderborn
> http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
> phone: +49-(0)5251-60-2329   fax: -3435  | 33098 Paderborn, Germany
> "Who disturrrbs me at this time?"  << Zaphod Beeblebrox IV >>   <*>

 
 
 

files that has not been modified for more than 4 hours

Post by Michael Sternber » Wed, 17 May 2000 04:00:00



> Is there a way to automatically 'touch' a file that is 4 hours back of
> current time?  I think my question is how to create a time stamp that
> is 4 hours back?

Please carefully re-read the previous posting again and tell us about the
context you need this in.  This is essential to get a useful answer.
Otherwise this question leads into a bottomless pit of idle speculation
where concept battles are fought.

Here's some rumbling of guns:  If you have GNU tools, touch --date='4 hours
ago' /tmp/marker; but then you probably also have GNU find which supports
+mmin and you can get by without touch altogether.  Without GNU,
and if you just need this for dt = a few hours it might be enough to fiddle
with the TZ variable and call "date +%m%d%H%M".  At the other extreme you
need a C program for lack of a sufficient script environment (notably
perl).

Regards,
--
Michael Sternberg,  Dipl. Phys.          | Uni-GH Paderborn
http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
phone: +49-(0)5251-60-2329   fax: -3435  | 33098 Paderborn, Germany
"Who disturrrbs me at this time?"  << Zaphod Beeblebrox IV >>     <*>

 
 
 

files that has not been modified for more than 4 hours

Post by Shawn Ye » Wed, 17 May 2000 04:00:00


I am writing this ksh script to zip all the files that are older than X hours.
My version of 'find' doesn't support the 'mmin' option and we have no GNU tools
here.  TZ variable?  I will do some research on that.  I am tempting to write a
C program to do this now.

Thank you so much for your advice!

Shawn



> > Is there a way to automatically 'touch' a file that is 4 hours back of
> > current time?  I think my question is how to create a time stamp that
> > is 4 hours back?

> Please carefully re-read the previous posting again and tell us about the
> context you need this in.  This is essential to get a useful answer.
> Otherwise this question leads into a bottomless pit of idle speculation
> where concept battles are fought.

> Here's some rumbling of guns:  If you have GNU tools, touch --date='4 hours
> ago' /tmp/marker; but then you probably also have GNU find which supports
> +mmin and you can get by without touch altogether.  Without GNU,
> and if you just need this for dt = a few hours it might be enough to fiddle
> with the TZ variable and call "date +%m%d%H%M".  At the other extreme you
> need a C program for lack of a sufficient script environment (notably
> perl).

> Regards,
> --
> Michael Sternberg,  Dipl. Phys.          | Uni-GH Paderborn
> http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
> phone: +49-(0)5251-60-2329   fax: -3435  | 33098 Paderborn, Germany
> "Who disturrrbs me at this time?"  << Zaphod Beeblebrox IV >>   <*>

 
 
 

files that has not been modified for more than 4 hours

Post by David Hasset » Wed, 17 May 2000 04:00:00



> I am writing this ksh script to zip all the files that are older than X hours.
> My version of 'find' doesn't support the 'mmin' option and we have no GNU tools
> here.

It does beg the obvious question. Why not install some GNU tools then?
As far a I can tell, to only actual tool you would need is GNU find. IMO
it would be easier to just install this than try to formulate your own
solution.

Just my 0.02 worth. ;-)

Cheers,

Dave. :-)