It might be relevant to know what OS you're using. I'm not a windows wizard, but I gather that the M$ OS has some deep locking mechanism, such that when a process opens a file for output, no other process gets to play with that file -- not no way, not no how.

In that case, you need to follow the previous advice: kill the current instance of the process, and restart it so that its log output is piped to some other process that will produce "rotation" log files. As indicated, log rotation scripts are already available, and of course, it could almost be as simple to cook up your own -- just decide what the rotation interval should be (hour, day, week) and how many intervals need to be kept at any given time (3, 7, 24, 31), come up with a suitable log file naming scheme, and have the rotation script delete the oldest file at each interval when it closes the current one and opens a new one.

On any unix-like OS, it should be possible to truncate a file even while some other process is writing to it. It can get messy, of course, depending on the nature of the output -- for a log file, probably the worst case would be ending up with a partial line at the beginning of the file.


In reply to Re: File Locking and other apps by graff
in thread File Locking and other apps by jmaya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.