[comp.sys.sequent] problem with find and NFS

pwolfe@kailand.kai.com (05/15/89)

I would like to have my daily maintenance scripts search all local filesystems
for temporary files and core dumps that haven't been accessed in three days and
delete them.  I would also like to do this without getting hundreds of the
following error messages every night for every top level directory on every NFS
mounted remote file system.

	find: bad status < dirname >
	find: bad directory < dirname2 >
	find: cannot open < dirname2 >

Our systems all use NFS and have many disk partitions from other systems
mounted permanently.  The problem stems from the fact that root does not have
"root access" on NFS file systems (yes, I know it is a configurable option, but
I like it that way).  Sequent has added the "-fstype" and "-prune" options to
the find command for this purpose, but I can't get these options to work.

The command:
	find / -type f \( -fstype nfs -prune \) \
		-o \( -name '#*' -o -name 'core' \) \
		-atime +3 -exec ls -aFgl {} \; -exec rm -f {} \;

produces the same error messages as:
	find / -type f \( -name '#*' -o -name 'core' \) \
		-atime +3 -exec ls -aFgl {} \; -exec rm -f {} \;


Patrick Wolfe	(pat@kai.com, {uunet,uiucuxc,sequent}!kailand!pat)
System Manager, Kuck and Associates, Inc.

hakanson@mist.CS.ORST.EDU (Marion Hakanson) (05/18/89)

In article <2400044@kailand> pwolfe@kailand.kai.com writes:
>. . .
>"root access" on NFS file systems (yes, I know it is a configurable option, but
>I like it that way).  Sequent has added the "-fstype" and "-prune" options to
>the find command for this purpose, but I can't get these options to work.
>
>The command:
>	find / -type f \( -fstype nfs -prune \) \
>		-o \( -name '#*' -o -name 'core' \) \
>		-atime +3 -exec ls -aFgl {} \; -exec rm -f {} \;
>
>produces the same error messages as:
>	find / -type f \( -name '#*' -o -name 'core' \) \
>		-atime +3 -exec ls -aFgl {} \; -exec rm -f {} \;


Whenever I want to convert an old pre-NFS "global find" command to run
on a machine with NFS mounts (and with a "find" which supports the
-fstype and -prune operators), I start with the template:

	find dirs rest-of-find-args

		becomes

	find dirs -fstype nfs -prune -o \( rest-of-find-args \)

Judicious use of escaped newlines and indenting can make the result
more readable, and some logical simplification may be possible, but
this simple approach works.  Your version causes find to have to
access the inode just to satisfy the "-type f" portion of the command,
before getting to the part that keeps find from crossing the remote
mount point.

-- 
Marion Hakanson         Domain: hakanson@cs.orst.edu
                        UUCP  : {hp-pcd,tektronix}!orstcs!hakanson

pwolfe@kailand.kai.com (05/18/89)

> /* Written by pwolfe@kailand.kai.com in kailand:comp.sys.sequent */
> /* ---------- "problem with find and NFS" ---------- */
> The command:
>	find / -type f \( -fstype nfs -prune \) \
>		-o \( -name '#*' -o -name 'core' \) \
>		-atime +3 -exec ls -aFgl {} \; -exec rm -f {} \;

Thanks to everyone who responded.  I know now that my the problem was caused by
my testing for "-type f" before pruning NFS file systems.  The following works:

	find / -fstype nfs -prune -o -type f -atime +3 \( -name '#*' \
	-o -name 'core' \) -exec ls -aFgl {} \; -exec rm -f {} \;

Patrick Wolfe	(pat@kai.com, {uunet,uiucuxc,sequent}!kailand!pat)
System Manager, Kuck and Associates, Inc.