Once again this is a great list. I got lots of replies. Lots of good
suggestions, and sever requests for a summary.
Thanks to all who responded.
My original:
>> Date: Tue, 20 Nov 90 10:12:42 EST
>>
>> SunOS 4.1, 4/380 server, 3/xx clients with 3's and 4's standalone on
>> the net.
>>
>> Problem:
>>
>> I am tired of getting messages from my find commands started from cron
>> which are supposed to remove certain files. The messages show that
>> the find is looking into nfs mounted file systems rather than only on
>> local file systems. This has been going on for some time and I have
>> tried several variations of -type and prune, none of which seem to
>> work. What do you all use that works?
>>
>> Here is an example
>>
>> find / '(' -name "#*" -o -name core -o -name "*~" ')' -a -atime +1 \
>> -fstype 4.2 -exec rm -f {} \;
>>
>> produced the following output:
>>
>> find: cannot chdir to /home/helicon/user1: Permission denied
>> find: cannot chdir to /home/helicon/user2/Mail/cap: Permission denied
>> find: cannot chdir to /home/helicon/user2/Mail/ask: Permission denied
>> . . . (many similar lines deleted)
>>
>> /home/helicon is an nfs mounted filesystem on the machine which
>> produced these messages. This same kind of thing happens on the file
>> server as well as on the standalone workstations.
>>
>> I have also used something like
>>
>> find / -name "*%" -atime +1 -exec rm -f {} \; -fstype nfs prune
>>
>> which doesn't seem to work correctly, either.
>>
>> Please mail responses to sjh@math.purdue.edu. I will summarize if
>> there is enough interest.
>>
>> Thanks in advance.
>> Steve.
>>
>> Steve Holmes purdue!sjh
>> Systems Administrator sjh@math.purdue.edu
>> Dept. of Mathematics (317) 494-6055
>> Purdue University, W. Lafayette, Indiana 47907
The best solution was that the find syntax is similar to C in that if
you put the -fstype nfs -prune as an -o ('or'ed) expression it will be
evaluated earlier in the search. What seems to work for me now
follows :
find / -fstype nfs -prune -o '(' -name "*%" -a -mtime +3 ')' -exec rm {} \;
as well as
find / '(' -name "*%" -a -mtime +3 ')' -exec rm {} \; -o -fstype nfs -prune
It turns out that the distributed 4.1 crontab has an example of this,
but I had overlooked it.
The best explaination follows: (along with other similar explaination)
>> From: Jay Plett <jay@princeton.edu>
>> Subject: Re: find only on local filesystems.
>>
>> Adjoining find operators have an implicit "and" between them.
>> As in a C expression, as soon as one operator evaluates false
>> any subsequent operators are ignored. Thus:
>> find A B C
>> is equivalent to
>> find A and B and C
>> if (B = 0), then C will never be evaluated.
>>
>> find / '(' -name "#*" -o -name core -o -name "*~" ')' -a -atime +1 \
>> -fstype 4.2 -exec rm -f {} \;
>> "-fstype 4.2" will only be evaluated AFTER at least one file has
>> passed the preceeding tests. Try "find / -fstype 4.2 ...".
>>
>> find / -name "*%" -atime +1 -exec rm -f {} \; -fstype nfs prune
>> "-fstype nfs prune" (should be '-prune') will be evaluated only
>> AFTER at least one file named "*%" has been found in an nfs
>> filesystem. Try:
>> find / \( -name "*%" -atime +1 -exec rm -f {} \; \) -o -fstype nfs pr
>> une
>> (both sides of -o (or) are evaluated).
>>
>> In any case, find will hang if a server is down. There is no way
>> to discover the fstype without statting the directory the filesystem
>> is mounted on.
>>
>> ...jay
Now for a few details.
Most of you got it right by pointing out that the -o is crucial
whether it comes first or last in the expression string. Several
suggested that putting if first would be faster (and a quick
experiment on a 4/40 seems to confirm that).
Several people claimed that it is a bug in SunOS 4.1. One person has
put the 4.0.3 find back on and is doing fine with that.
Several pointed out that I had a mistake in the example I gave. One
mistake was a typo (the missing - in front of prune) the other wasn't
(the missing -o in front of -fstype).
Several people suggested using the -xdev option which restricts the
search to the filesystem specified, but that requires a find
for each filesystem.
I got a couple of shell scripts for getting around the problem.
Just in case some one is interested here they are:
>> From: bien@aerospace.aero.org
>> Subject: Re: find only on local filesystems.
. . .
>>
>> We use the following to get around the problem. This is the /bin/sh
>> version:
>>
>> # We don't want to bother searching through read-only, nfs or swap file
>> # systems so we look at /etc/fstab to create the list of file systems
>> # to be searched. We delete /tmp from the list since this is cleaned out later
>> .
>> SEARCH=`awk '{ if ((($3 ~ /^4\.2$/) || ($3 ~ /^omnifs$/)) && ($4 ~ /^rw$/)) {pr
>> int $2} }' /etc/fstab \
>> | sed -e 's/\/tmp$/ /'`
>>
>> find $SEARCH -xdev \
>> \( \
>> \( -name core -size +0 \) -o \
>> -name ',*' -o \
>> -name '#*' -o \
>> -name '.,*' -o \
>> -name '*%' -o \
>> -name '.*%' -o \
>> -name '*.CKP' -o \
>> -name '.*.CKP' -o \
>> -name '*.BAK' -o \
>> -name '.*.BAK' -o \
>> -name '*~' -o \
>> -name '.*~' \
>> \) \
>> -atime +3 -exec /bin/rm -f {} \; 2> /usr/tmp/$$
>>
>>
>> Here's the /bin/csh version:
>>
>> # This doesn't work because of a bug in Sun's find.
>> # We don't want to bother searching through nfs or swap file
>> # systems so we look at "-fstype 4.2" filesystems only.
>> #find / -fstype 4.2 -name .rhosts -ls -exec cat {} \; >> /tmp/x$$
>>
>> # We don't want to bother searching through read-only, nfs or swap file
>> # systems so we look at /etc/fstab to create the list of file systems
>> # to be searched.
>> set SEARCH=`awk '{ if (($3 ~ /^4\.2$/) && ($4 ~ /^rw/)) {print $2} }' /etc/fsta
>> b`
>> find $SEARCH -xdev -name .rhosts -ls -exec cat {} \; > /tmp/x$$
>>
>>
>> --Cheryl Bien
>> bien@aerospace.aero.org
Many thanks, once again to:
From: "Matt Crawford" <matt@oddjob.uchicago.edu>
From: "Michael J. Saletnik - Local Unix Wizard's Apprentice" <icarus@end.tufts.edu>
From: "alex;923-4483" <alexl%daemon.cna.tek.com@RELAY.CS.NET>
From: Andreas Koppenhoefer <koppenh@dia.informatik.uni-stuttgart.de>
From: Bill Vaughn <bill@cvs.rochester.edu>
From: Dan Williams <dan@ufcia.health.ufl.edu>
From: David Wiseman <magi@csd.uwo.ca>
From: Gene.Saunders@west.sun.com (Gene Saunders - network ambassador)
From: Jay Plett <jay@princeton.edu>
From: John DiMarco <jdd@db.toronto.edu>
From: John Hasley<hasley@andy.bgsu.edu>
From: Paul Gill <paul@concour.cs.concordia.ca>
From: Prabal K. Acharyya <prabal@element.eng.ohio-state.edu>
From: Wayne Little <rwl@ee.umr.edu>
From: aggarwal@nisc.jvnc.net (Vikas Aggarwal)
From: aptcorp!venus!brian@central.sun.com (Brian Holgate)
From: att!alux5!lbd@ecn.purdue.edu
From: aydt@cymbal.cs.uiuc.edu (Ruth Aydt)
From: bien@aerospace.aero.org
From: bob@kahala.soest.hawaii.edu (Bob Cunningham)
From: bob@omni.com (Bob Weissman)
From: brian@cimage.com (Brian Kelley)
From: casterln@are.berkeley.edu (Gary Casterline)
From: dmorse@sun-valley.stanford.edu
From: era@niwot.scd.ucar.edu (Ed Arnold)
From: execu!unisql!alfred@cs.utexas.edu (Alfred Correira)
From: honasa!vk@dynamo.ecn.purdue.edu (Vivek Kalra)
From: jrich@ucrmath.ucr.edu (john richardson)
From: lisa%beldar@ucsd.edu (Lisa)
From: mike@inti.lbl.gov (Michael Helm)
From: millidc!maize!djm@uunet.uu.net (Drew Montag)
From: pbg@cs.brown.edu (Peter Galvin)
From: pjs@euclid.jpl.nasa.gov (Peter Scott)
From: rcsmith@anagld.analytics.com (Ray Smith)
From: rfinch@water.ca.gov (Ralph Finch)
From: rich%idacrd@princeton.edu (Richard Schultz)
From: sbradley@iwarp.intel.com (Seth Bradley)
From: sjh@helicon.math.purdue.edu
From: stpeters@dawn.crd.ge.com (Dick St.Peters)
From: timsmith@sun.com (Timothy G. Smith - Technical Consultant Sun Baltimore)
From: trinkle@cs.purdue.edu
From: yamada-sun!eric@nosun.west.sun.com (Eric Hanchrow)
From: yih%atom@cs.utah.edu (Benny Yih)
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:05:59 CDT