From owner-freebsd-questions@FreeBSD.ORG Sat Aug 14 23:39:40 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 80C5E16A4CE for ; Sat, 14 Aug 2004 23:39:40 +0000 (GMT) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1711843D1F for ; Sat, 14 Aug 2004 23:39:39 +0000 (GMT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) i7ENdXHO014686 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 15 Aug 2004 00:39:33 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i7ENdXFh014685; Sun, 15 Aug 2004 00:39:33 +0100 (BST) (envelope-from matthew) Date: Sun, 15 Aug 2004 00:39:33 +0100 From: Matthew Seaman To: "Paul A. Hoadley" Message-ID: <20040814233933.GA14322@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , "Paul A. Hoadley" , freebsd-questions@freebsd.org References: <20040814230143.GB8610@grover.logicsquad.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline In-Reply-To: <20040814230143.GB8610@grover.logicsquad.net> User-Agent: Mutt/1.5.6i X-Greylist: Message not sent from an IPv4 address, not delayed by milter-greylist-1.5.3 (smtp.infracaninophile.co.uk [0.0.0.0]); Sun, 15 Aug 2004 00:39:34 +0100 (BST) X-Virus-Scanned: clamd / ClamAV version devel-20040705, clamav-milter version 0.74a on smtp.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.64 X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk cc: freebsd-questions@freebsd.org Subject: Re: find -exec surprisingly slow X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2004 23:39:40 -0000 --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Aug 15, 2004 at 08:31:43AM +0930, Paul A. Hoadley wrote: > Hello, >=20 > I'm in the process of cleaning a Maildir full of spam. It has > somewhere in the vicinity of 400K files in it. I started running > this yesterday: >=20 > find . -atime +1 -exec mv {} /home/paulh/tmp/spam/sne/ \; >=20 > It's been running for well over 12 hours. It certainly is > working---the spams are slowly moving to their new home---but it is > taking a long time. It's a very modest system, running 4.8-R on a > P2-350. I assume this is all overhead for spawning a shell and > running mv 400K times. Is there a better way to move all files based > on some characteristic of their date stamp? Maybe separating the find > and the move, piping it through xargs? It's mostly done now, but I > will know better for next time. Yup. Invoking mv 40,000 times is not particularly efficient. Something like this would have been better: find . -atime +1 -print0 | xargs -0 -J % mv % /home/paulh/tmp/spam/sne/ xargs defaults to taking up to 5,000 arguments from it's stdin to generate the mv commands (or up to ARG_MAX - 4096 =3D 61440 bytes), so that would have done the job with only 8 or so invocations of mv. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --tKW2IUtsqtDRztdT Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (FreeBSD) iD8DBQFBHqK1iD657aJF7eIRAo8CAJ90US/h4zGI8Re1A8rIt58kCzwr1ACfTLqw rweM21V1+MW5pZppe9pO+s8= =SZHL -----END PGP SIGNATURE----- --tKW2IUtsqtDRztdT--