in reply to Re: Random script crashes related to File::Copy (care)
in thread Random script crashes related to File::Copy

Let me add a little more information. This script transfers several dozen files per day. The files are either plain text, mp3 or wav audio files. It may run flawlessly for several days, then it might crash 5 or 6 times in one day.

If it crashes during the transfer attempt of a file, when restarted, it transfers the file without problem.

Hence, I believe the problem is somehow timing related rather than the actual command structure. If the problem was really related to "Invalid cross-device link" errors or the like, would that not then cause the script to crash every time? I would think that type of error is more a result of an underlying problem.



BTW, this is my first post on Perl Monks. I am truly impressed by the speed and quality of responses. Thank you all very much. I am anticipating a solution soon, thanks to your collective knowledge and kindness.



Michael
  • Comment on Re^2: Random script crashes related to File::Copy (care)

Replies are listed 'Best First'.
Re^3: Random script crashes related to File::Copy (care)
by tye (Sage) on Apr 29, 2009 at 16:58 UTC

    How do you know that the file has finished being written before you start copying it? In such situations, I usually recommend that you have a standardized naming convention for "still writing to the file" like "*.tmp" and then have whatever process is writing the file rename it to remove the ".tmp" after it is finished writing it.

    If after you have (already?) solved the above concern, the "text file busy" problem (besides causing me to research what that error really means which might even lead me to reading OS source code) would lead me to detecting move() failing and leaving $! set to ETXTBUSY (from Errno) and then just sleeping and retrying a couple of times.

    - tye        

Re^3: Random script crashes related to File::Copy (care)
by ikegami (Patriarch) on Apr 29, 2009 at 17:01 UTC

    Hence, I believe the problem is somehow timing related rather than the actual command structure. If the problem was really related to "Invalid cross-device link" errors or the like, would that not then cause the script to crash every time

    Not all. After all, "Text file busy" means *something else* (another handle? another process?) is keeping the file "busy" (mmapped?).

      Your response appears to be a result of a faulty parsing of English. "If X, then would crash every time" vs "Not every time, because Y could be timing related". While "X" is "not Y".

      - tye        

        I can't makes sense of your sentence fragments. I read

        If the problem was really related to "Invalid cross-device link" errors or the like, would that not then cause the script to crash every time

        as

        If the problem was really related to "Invalid cross-device link" errors or the like, I would expect the script to crash every time the error is encountered. Isn't that so?

        and I interpreted "or the like" to mean "or other errors in the displayed strace". Is that wrong?