Need Assistance with gzipping files with same names

Hello,

I have an issue on a webserver where I have a perl script rotating and moving the logs to an archive directory where they are gzipped. This is working fine. The problem is when there is tracing enabled on my webserver where the tracelogs are rotated whenenver they reach 100Meg and they are given following filenames - tracelog.out.[1-9]. So the output would be simliar to following:

-rw-r--r-- 1 nobody group 5582894 Jan 6 20:46 tracelog.out.9.gz
-rw-r--r-- 1 nobody group 10538971 Jan 7 00:05 tracelog.out.9

Since there is a gzip file currently in same directory- I cannot gzip the tracelog.out.9 and thus diskspace is filling up.

I want to enhance my script to capture the tracelogs and rename them during the rolling cycle to a uniq name so the archive script will work every night.

Anyone know of quick way to do this?

How are the .[0-9] filenames decided? We'll have to see your script to fix it of course.

Thanks Corona 688..

What I am looking for is to build a script to only run when the tracelogging functionality is turned on the apache server. This functionality automatically rolls the trace.log once it reaches 100Meg in size. We did this on purpose so that vendors could easily read the files. So when the file reaches 100 Meg, it rolls it and renames the file to tracelog.1. This then go in sequencial order - we have had this run to almost the 200 range. I am looking for the right logic to do the following:

  1. locate the trace.log.# and sort them by number
  2. rename the trace.log# to unique file name structure in order to keep the archive file sequence intact.
  3. gzip the new unique file name created.

Again this would be a secondary script only run when the trace functionality is enabled. If you could help with the logic I would be most greatful.