Nothing posted here so far will help with that. If the 3 CPU-second limit is for only one process, you can avoid it by breaking up the job into several smaller jobs, then executing all of them; or by monitoring how much CPU time you've used, and right before you use your quota up simply forking a new process and continuing the work there. Here's a small code snippet that demonstrates this forking; note that it abuses signal handlers, and so may not work on all platforms. It generates 10,000,000 pseudorandom numbers, printing every 1,000,000th. It should run the same with or without forking.
#!/usr/bin/perl -w $SIG{ALRM}= sub { my($user,$system) = (times)[0,1]; my $totaltime = $user + $system; if ($totaltime > 1.5) { if (fork() != 0) { # No error checking. Bad Monk! wait; exit(0); } } alarm(1); }; $| = 1; alarm(1); # Comment out to not use fork srand(0); for(my $i=0;$i<10_000_000;$i++) { if (($i % 1_000_000) == 0) { printf "%05d (pid %05d)\n", int(rand() * 10_000),$$; } }
The fun part about this approach is that it's actually much harder on the server than if they just let you bypass the stupid limit. If you're lucky, they'll notice this and work with you to make your and their lives better. If you're unlucky, they'll just shut off your account.

If the limit is on that child and all of its children, you're pretty much screwed.

Apart from hack value, though, the real solution is to make your code more efficient, or else find a hosting provider that better meets your needs.


In reply to Re: Re: Limiting script cpu time by sgifford
in thread Limiting script cpu time by sdbarker

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.