Have a look at IPC::DirQueue, or use files in the file system as jobs and directories as their respective state yourself. On sane (that is, non-NFS) filesystems, rename is atomic and hence you can acquire a job by renaming it to "state1/$filename.$$", and once it is completed, rename it to "state2/$filename" for others to see. Restarting a job is as easy as renaming the corresponding file, and finding abandoned jobs means checking whether the PID corresponding to the file still exists.

If you want to expand this scheme across machines (with a shared directory holding the data, see my caution against NFS above), note that the PID is not unique anymore, so you will need to add the machine name as well as the PID to the file.

I haven't used IPC::DirQueue myself, but I have worked with similar schemes, and they have the benefit that you have lots of user tools already available. They don't scale well over 1000 jobs due to file system limitations and the rescanning, but if you have higher requirements, a dedicated (single point of failure) job queue server like SMTP might be a better option.


In reply to Re: Persistent File Queue recommendation requested by Corion
in thread Persistent File Queue recommendation requested by r1n0

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.