Just ran into a temp dir with a bazillion files in it.  What I really
wanted was an option to "fuser"  (let's call it -x for now) that causes a
non-directory argument to be deleted if nothing is using it; that way, I
could have done the safest thing I could think of to clean out that
directory, something like:

find dir -type f -name 'pat*' -atime +5 -exec fuser -x {} +

By checking on both non-recent last use _and_ nothing having it open,
I figure I'm being about as safe as possible, given that there's no way to
tell whether some process might have an interest in a file whose name they
may _know_ but that they aren't currently using.

But there's no easy way to do that; I came up with something, but
it was quite ugly by comparison.

That specific approach might not be necessary; I'd be just as happy with
a pair of options that caused fuser to produce output only for those files
that were (or under the opposite option, were not) in use; I could always
crank that through xargs (although that's not as safe in the face of
arbitrary bytes in the file name as having fuser act directly; similar to
the use of find and xargs vs find and the more recently documented +
instead of escaped semicolon).

Yet another alternative that might be ok (and easier still) would be adding
a -inuse option to find; in which case I could have done

find dir -type f -name 'pat*' -atime +5 ! -inuse -exec rm -f {} +

which would have been exactly what I wanted...

Anybody else think that one or more of these (I particularly like the
-inuse, now that I think about it) would be worth having?
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to