Are you on *nix or Windows? It's not impossible, but on *nix it will be tricky to have cron start the daemon while connected to a real terminal, as cron just doesn't work the way you'd like. You probably would have to write a wrapper script for starting it under cron and connecting your daemon's I/O to the user's console.

For writing a wrapper, take a look at Net::Server. It handles all the low-level I/O for you, allowing you to write just the high level code.

It has several different ways of operating, so one may be right for your application. It takes care of things like PID files and backgrounding the process.

I recently implemented a simple server using Net::Server and found it had some useful examples. In my case examples/samplechat.pl was handy to examine.


In reply to Re: cron with perl by tod222
in thread cron with perl by Pstack

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.