[rt-users] rm sessiondata from crontab...

Ferguson, Kevin KFerguso at chi.navtech.com
Fri Jan 18 14:47:31 EST 2002


Hi,

You are right that -exec is a resource hog but for the wrong reason.
-exec gets passed a single file and so creates a separate /bin/rm process 
for every file encountered.

Unfortunately, your example is just as inefficient as using -exec (at least
for GNU find on my Slackware system).  The -i switch explicitly says to 
replace the braces with the input and defaults to ONE line at a time.  Since
find produces output one filename to a line, your xargs is calling /bin/rm
for
each file, just like -exec would.  If you call xargs without the -i switch
like this, 

/usr/bin/find /opt/rt2/WebRT/sessiondata -type f -amin +600 -print | 
/usr/bin/xargs /bin/rm

xargs will accrue as much input as possible that will fit on a single 
command line and pass that to /bin/rm in one swell foop.  Voila, one call
to /bin/rm to delete many files.  HTH.

ttfn,
kevin


> 
> 
> Hi,
> 
> Also, for efficiency/reliability purposes you might want to try:
> 
> /usr/bin/find /opt/rt2/WebRT/sessiondata -type f -amin +600 -print |
> /usr/bin/xargs -i /bin/rm '{}'
> 
> IIRC, -exec is kind of a resource hog. xargs gets around limits on 
> number of arguments because -exec can crap out if the number of 
> files returned is large. xargs is pretty useful but not well 
> advertised.
> 
> hth,
> 
> -- Bob
> 
> On 18 Jan 2002, at 11:49, Adrian Galindo wrote:
> 
> > Kristopher Lalletti escribió:
> > > 
> > > I'm trying to get find with -exec to work .. and I'm not 
> getting any
> > > luck
> > > 
> > > Here's the cmdline from the RT docs, for the -exec , syntax looks
> > > great from the man pages, but I keep getting 
> "/usr/bin/find: missing
> > > argument to `-exec'".
> > > 
> > > /usr/bin/find /opt/rt2/WebRT/sessiondata -type f -amin +600 -exec
> > > /bin/rm '{}' ;
> > > 
> > > Any ideas?   I wouldn't be surprised that RedHat 7.2 
> would use some
> > > sort of their own /usr/bin/find, but I want to make sure 
> if I'm not
> > > missing something..
> > 
> > You miss the backslash at the end.
> > The correct is:
> > /usr/bin/find /opt/rt2/WebRT/sessiondata -type f -amin +600 -exec
> > /bin/rm '{}' \;
> > 
> > man find for more information.
> > 
> > Greetings
> > Adrian Galindo
> > 
> 
> 
> 
> _______________________________________________
> rt-users mailing list
> rt-users at lists.fsck.com
> http://lists.fsck.com/mailman/listinfo/rt-users
> 




More information about the rt-users mailing list