Andrea Aime wrote:
> + find /var/www/html/geoserver/1.7.x -name 'geoserver*bin.zip' -mtime +6
> -exec rm '{}' ';'
> + find /var/www/html/geoserver/1.7.x -name 'geoserver*war.zip' -mtime +6
> -exec rm '{}' ';'
> + find /var/www/html/geoserver/1.7.x -name 'ext-*' -type d -mtime +6
> -exec rm -rf '{}' ';'
> find: /var/www/html/geoserver/1.7.x/ext-2009-08-11: No such file or
> directory
> find: /var/www/html/geoserver/1.7.x/ext-2009-08-12: No such file or
> directory
> However I don't understand what is going on there... how can it be
> that the directory is found (the names comes from somewhere no?)
> and then it's missing (and btw, it's find itself complaining,
> rm -rf would not).
I have seen exactly this behaviour running find locally. It has always
bugged me, even though it works. Now I have the solution: use the find
-depth flag.
What is going on is that:
(1) find locates a matching directory
(2) runs your arbitrary command on it
(3) descends into the matching directory looking for more matching
directories.
Unfortunately, because (2) removes the directory, (3) fails. The find
continues, but returns a failure error code. The solution is to add
-depth as the first non-path argument to find to cause it to process the
contents of each directory before the directory itself (i.e. depth first).
For example:
$ mkdir -p a/b
$ find . -name a -exec rm -rf {} \;
find: `./a': No such file or directory
$ echo $?
1
(Return code 1 is a failure.)
$ mkdir -p a/b
$ find . -depth -name a -exec rm -rf {} \;
$ echo $?
0
(Return code 0 is a success.)
Success!
--
Ben Caradoc-Davies <[email protected]>
Software Engineer, CSIRO Exploration and Mining
Australian Resources Research Centre
26 Dick Perry Ave, Kensington WA 6151, Australia
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel