ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: delete directory structures older than X days
Date Tue, 16 Jun 2009 18:13:14 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message