Quote:> Hi all,
> i'm having a lot of problems with 'find', and I get the
> feeling they are well known problems, I was wondering if
> anyone would be able to help me out. The problem is that
> the -local switch doesn't seem to work. It reads the
> file /etc/dfs/dfstypes or something like that for a list
> of remote file system types, and is SUPPOSED to skip the
> file systems of those types when searching, but it
> doesn't. I have tried various ways to get around this,
> including -fstype nfs -prune. I can't seem to get it to
> work! All I want is to have 'find' search the hard drives
> for core files and remove them.
You can work around any such problem by generating the list of
directories on which "find" is expected to work. For example:
========================= cut here ============================
#! /bin/sh
#
# Do yourself a favor and notify the users of the policy that this
# script implements!
#
# The clause && substr($1,1,5)!="/vol/"
# is intended to exclude media mounted via the volume manager, under
# the assumption that such media tends to be a private rather than
# shared resource. Also, by keeping "find" out of volume manager mounted
# directories, it prevents this script from causing "eject" to fail
# unexpectedly due to the filesystem being busy by something not
# running at the initiative of the console user.
#
# One could of course remove that, but I don't recommend it.
#
# Days to allow a core file to linger, in case someone actually wants
# to use it to _fix_ the reason it was produced in the first place.
#
GracePeriod=7
#
PATH=/usr/bin;export PATH
for Dir in \
` awk '( $3=="ufs" || $3=="tmpfs") && substr($1,1,5)!="/vol/" {print $2}' \
/etc/mnttab `
do
find "${Dir}" -mount -mtime +"${GracePeriod}" -type f -name core \
-print | xargs rm -f
done
========================= cut here ============================
The -mount (or equivalent -xdev) option of "find" is important:
it prevents "find" from crossing a mount-point into another
filesystem.
One could go further and have a file that looked like:
# mount-point grace_period
/tmp 1
/var/tmp 1
/export/home 7
and write a script that operated against such a file instead,
to allow the additional flexibility. But that's overkill for
a simple example.
--
ftp> get |fortune
377 I/O error: smart remark generator failed
Bogonics: the primary language inside the Beltway