ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: Rotating log files
Date Fri, 06 Jul 2001 13:39:46 GMT
--- Ingmar Stein <> wrote:
> I use Ant for a nightly build system which creates a new directory each
> time it is run via a cron job using
>   <tstamp/>
>   <property name="path.dlogs" value="${path.logs}/${DSTAMP}"/>
>   <mkdir dir="${path.dlogs}"/>
> Now, I wanted to archive all log directories except the latest, say 10,
> entries into a ZIP archive.
> Does anyone know if this is possible with Ant?

Create an "excludesfile" to specify to <zip> that contains that latest 10
files. How you do that is up to you, depending on how portable you need it
to be. Eg, if your logs are on a Unix box, you could do something as
simple as <exec> a 'sh' that runs (in the log-file directory):
ls -lt | grep -v -e "^d" -e "^total" | head | awk '{print $NF;}' > ex.logs

If you need more portability, and you know Java, you could write a task to
do it (should be pretty straightforward to do). Or write a perl script,



Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail

View raw message