If you delete via unlink (as opposed to truncation, for example) and roll via rename (not by copying), you may not have to worry. If you unlink a file that another process is reading, the file will continue to exist until the other process closes the file. This is the basis for an old trick of opening, then unlinking, a file, so it will "disappear" even if the machine crashes. The file can be written and read using the open file handle, even though it has no visible presence in the file system. Similarly, a file that is being appended to by another process can safely be renamed within the file system. The open file is "known" by its inode number, not by the name by which it was opened, and the inode number is unaltered by a local rename.

Don't rely on atime. Many, perhaps most, linux file systems no longer maintain it.


In reply to Re: Looking for log files with open file handles in linux. by jpl
in thread Looking for log files with open file handles in linux. 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.