If you are in control of the files coming into the directories in question, there is a much simpler technique available that doesn't rely on file locking. This makes things much more robust.

On the flip side, you need the cooperation of the file provider.

Arrange to have things so that the provider sends two files, the data file itself (foobar.txt) and when all is done, files closed, buffers flushed, speakers burst, amps all wet (ah no, that's a Sonic Youth song I'm thinking of)... you then create a second file named 'foobar.txt.check'.

Creating the check file can be as simple as open F, 'foo.txt.check' and close F. You then just have to look for check files. If one exists, you are guaranteed that the file it refers to has been written in its entirety.

After you are done with the file, you can at least delete the check file, so that you don't attempt to reprocess it. From there, you can either also delete the corresponding data file, or else the provider can later scan the directory, and delete any data files for which there no longer corresponds a check file.

--
g r i n d e r

In reply to Re: General Question: File triggered job launcher by grinder
in thread General Question: File triggered job launcher by Bjoern

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.