In a follow up to my previous post on Jrun Processor Pegging Issues and Solutions I was intrigued by an idea given to me by Steven Erat. The problem is that the "-err" and "-out" logs do not roll over like the event logs. This is a problem that is slated to be fixed in the next version. To "fix" this problem Steven thought it might be possible to move or delete the file using CFFILE without restarting CF. He reasoned that while windows could not defeat the lock, perhaps CF could defeat it because it owned the lock to begin with. Here's what I found.
If you try to delete the file:
When I tried the write attribute like this:
The thing to note here is that the data is now gone. To quote Monty Python's Dead Parrot sketch, "It is deceased, it is no more, it has passed away, crossed over, pushing up daisies, gone toward the light, kicked the bucket, given up the ghost, bought the farm..." So before you try the code above, copy the file using windows so you have a copy of the data if you need it.
Why copy it using windows? Why not just do both operations using CFFILE? Ah... well, if you read my post from yesterday (5/2/2006) you will note that the problem we are most often trying to solve is that the "out" and "err" log files grow quite large (hundreds of megabytes perhaps even gigabytes) and do not "roll over" like the other "event" style log files. This creates a problem and I suspect it is the culprit in at least one case of JRUN pegging at 100%. Have you ever tried to copy a very very large file using Coldfusion? Quite simply, Coldfusion is not the best tool for this sort of thing. I suspect that Coldfusion reads the entire file into memory before writing it out to disk. If it's a very large file, it may even exhaust your server resources. Instead, use an alternative method for backing up the file, then overwrite it using the code above. This will give you the best of both worlds.