ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sascha Ernst <sascha.er...@living-e.com>
Subject AW: delete directory structures older than X days
Date Wed, 17 Jun 2009 11:38:25 GMT
Hello,

this tasks does not do what I want.
1) it builds a huuuge fileset (a complete building session ends with ~300K files and more
than 10GB)
2) it leaves newer files (which might be touched during debugging of failed builds)
3) it deletes newer folders if the content is older than the date

My structure looks like this:
13.05.2009  14:11    <DIR>          NBS-run-20090513130209
14.05.2009  00:40    <DIR>          NBS-run-20090514000143
15.05.2009  00:41    <DIR>          NBS-run-20090515000237
16.05.2009  00:42    <DIR>          NBS-run-20090516000221
17.05.2009  00:42    <DIR>          NBS-run-20090517000157
18.05.2009  00:42    <DIR>          NBS-run-20090518000126
19.05.2009  10:56    <DIR>          NBS-run-20090519000110
20.05.2009  00:40    <DIR>          NBS-run-20090520000252
....

And I want ant to delete those NBS-run-folders which are older than xy-days.
Completely. Regardless if the content of these folders (files or subfolders) are
oewer or older or whatever).
The content of the NBS-run-folders wich are not older than xy-days must not
be touched in any way.

BTW: the format hint didn't work either.

I'll try fiddeling around with dirset again.

///sascha///

-----Urspr√ľngliche Nachricht-----
Von: David Weintraub [mailto:qazwart@gmail.com] 
Gesendet: Dienstag, 16. Juni 2009 20:13
An: Ant Users List
Betreff: Re: delete directory structures older than X days

I just ran a test:

<project name="test.proj" default="test">
    <target name="test">
    <delete
        verbose="true"
        includeemptydirs="true">
        <fileset dir="${basedir}">
        <exclude name="build.xml"/>
        <date datetime="04/10/2009 12:00 AM"
            when="before"/>
        </fileset>
    </delete>
    </target>
</project>


And, this works great.

One of the things I noticed is that the directory timestamp is updated when
a file in that directory is deleted. Wonder if your "checkdirs" parameter
might be affecting that.

Try copying the build.xml I have up here, and manually modify the timestamp
in the <date> selector to fit your needs. See if this deletes the files
you're looking for.

If it does, then try using your "borderline.timestamp" routine to fill in
the timestamp and see if that does what you think it should do. That might
be a problem because you have "17:32 PM" as a time instead of "5:32 PM".
Change your format from:

MM/dd/yyyy *HH*:mm aa

to:

MM/dd/yyyy *hh*:mm aa

(Note the lowercase "h" specifying the hour!).


On Tue, Jun 16, 2009 at 11:58 AM, Sascha Ernst <sascha.ernst@living-e.com>wrote:

> Hello,
>
> I googled the mailing list archive and found a matching solution based on
> javascript for ant 1.5.
>
> I'm using ant 1.7.1 and tried this to delete NBS-folders
> (NightlyBuildSystem) older than a specific amount of time.
>
>  <target name="delete.old.stuff"
>          depends="init"
>          description="delete all NBS stuff which is older than a specific
> amount of time">
>
>    <!-- start the timer -->
>    <stopwatch name="timer.delete.old.stuff"/>
>
>    <!-- first calculate the borderline timestamp -->
>    <tstamp>
>      <format property="borderline.timestamp" pattern="MM/dd/yyyy HH:mm aa"
>              offset="${deletion.threadshold}" unit="day"/>
>    </tstamp>
>
>        <echo message="borderline.timestamp=${borderline.timestamp}" />
>
>        <!-- now delete all NBS checkouts and stuff older than that
> boderline timestamp -->
>        <echo message="delete ${NBS.dir.prefix}** in ${nbsdir} before
> ${borderline.timestamp}" />
>        <delete includeemptydirs="true" verbose="true">
>          <dirset dir="${nbsdir}" includes="${NBS.dir.prefix}**">
>            <date datetime="${borderline.timestamp}" when="before"
> checkdirs="true"/>
>          </dirset>
>        </delete>
>
>        <!-- now determine the  artifact folder -->
>        <property name="artifact.dir"
> value="${builddir}/CruiseControl/artifacts/${projectname}" />
>
>        <echo message="artifact.dir=${artifact.dir}" />
>
>        <!-- now delete all artifacts and stuff older than that boderline
> timestamp -->
>        <echo message="delete **/**/* in ${artifact.dir} before
> ${borderline.timestamp}" />
>        <delete includeemptydirs="true"  verbose="true">
>          <dirset dir="${artifact.dir}" includes="**/**/*">
>            <date datetime="${borderline.timestamp}" when="before"
>  checkdirs="true"/>
>          </dirset>
>        </delete>
>
>        <!-- print out timer and reset it -->
>    <stopwatch name="timer.delete.old.stuff" action="total"/>
>
>    <echo message="DONE : delete.old.stuff" />
>  </target>
>
> Unfortunately this construction does not delete anything :-(
>
> The console says this:
> delete.old.stuff:
>     [echo] borderline.timestamp=06/06/2009 17:32 PM
>     [echo] delete NBS-run** in F:/NightlyBuildSystem before 06/06/2009
> 17:32 PM
>     [echo]
> artifact.dir=F:\NightlyBuildSystem/CruiseControl/artifacts/Mailminder NBS
>     [echo] delete **/**/* in
> F:\NightlyBuildSystem/CruiseControl/artifacts/Mailminder NBS before
> 06/06/2009 17:32 PM
> [stopwatch] [timer.delete.old.stuff: 0.844 sec]
>     [echo] DONE : delete.old.stuff
>
> Is there something I'm doing completely wrong?
> Is there any possibility to delete such old stuff without using javascript
> anyway?
>
> Thanks for your time and your help
>
> Regards
>
> ///Sascha Ernst///
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message