Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • ...whenever I use the filesystem as a message queue, the first step of my process is always 'copy the file to a working directory, then delete the original' to prevent two instances from gobbling up the same file.
    • Surely that should be "move" rather than "copy", because move is atomic?


      • Yep, you understood what I meant.
        • You also have to make sure that each process uses a different working directory, generally thatwould be one that includes the process ID as part of the name.
          • Not really -- since you're ensuring that only one process has access to the file you shouldn't need separate working directories. Additionally, you can either ensure the original filename is unique across time or move the file to a unique name. (What 'unique' means depends on your process -- if you know you're only running a process every five minutes then using time() or pid + time() as a filename should be ok.)
    • So what do you do if the process, for some reason, is unable to finish it's work. There is no simple way to start working on the fil again.

      We usually use file-locking on per-job lock files to ensure that there are no simultaneous runs of the same job.