SUMMARY: Using find to remove files

From: <grant_at_skydesk.com>
Date: Fri Oct 12 2001 - 11:02:41 EDT
Wow, the response to this was overwhelming. Too many people to thank
individually.

Let me say that maybe I should have been more complete in my email.  I could
have added that allowing find to use files that are over 24 hours, before I
even hit 24 hours, would have filled up my small RAID partition of 160 GB.

The responses fell into only a few categories.  The first and by far the
most popular response was to use find with something like:

find . -mtime +6 -exec rm {} \;

This won't work because with the standard Solaris find, +6 refers to days
not hours like I need.

The next most popular response was to use touch and then use find with
the -newer option like this:

touch -acm MMDDhhmm foo
find . -newer foo -exec rm {} \;

This is a good and creative idea.  With this, you need to know the file's
names for touch to work correctly.  A little bit easier would be to put the
current time into a file, and then six hours later use find with -newer.

A few people suggested using perl and/or C.  Probably the fastest way to do
it.  Some even offered their code for it (thanks, as it helps me to learn C
some more).

What I ended up doing was download GNU find and compilind and installing
that.  Since GNU find has a -mmin n option.  From the man page for GNU find:

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

Thanks again to one and all!

Grant




Original message:

Hi gurus.

Does anybody know of a way to use find to remove files that are older
than 6 hours?  The man page didn't turn up anything, and I didn't see
anything in dejanews.  The system is an E450 running Solaris 8.  Thanks!

Grant
Received on Fri Oct 12 16:02:41 2001

This archive was generated by hypermail 2.1.8 : Wed Mar 23 2016 - 16:32:33 EDT