I agree with this suggestion that pileofrogs provided. But I wonder if there might be complications for you...

1. Rather than just truncating the log file, should you be "rotating" it (saving some amount of recent log history)? There are perl modules for log file rotation, but basically, it's just a matter of renaming the "current" log file at, say, the end of each day and creating a new empty log file (e.g. "foo.log" is renamed to "20060821.foo.log", and a new "foo.log" is created; you retain some number of daily logs, and each day you just delete the oldest one).

2. Is the log file being written to by a process that runs continuously and keeps the log file open for output at all times? If so, could this interfere with a separate cron job that tries to open/truncate the log file? (I'm not a windows user, so I don't know from personal experience, but I've seen some discussions about how output file locking works on windows.)

If the answer to 2 is "yes", you presumably have to end the process in question, do whatever needs to be done to the log file, and restart the process. Or else you have to reconfigure the process, if possible, so it opens and closes the log file appropriately, or handles daily log rotation as part of its normal behavior.


In reply to Re: Cleaning file by graff
in thread Cleaning file by Anonymous Monk

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.