You say "compiled" so I am not sure what language the script is in.<br><br>But there is a way to prevent a script from running more than a certain<br>number of seconds. For example PHP provides a parameter for exactly<br>

that, and you can change it depending on your needs.<br><br><a href="http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time" target="_blank">http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time</a><br>

Or even doing it programatically (if you have the permission).<br><br><a href="http://php.net/manual/en/function.set-time-limit.php" target="_blank">http://php.net/manual/en/function.set-time-limit.php</a><br><br>For shell scripts, you can do that like so:<br>
<br><span style="font-family: courier new,monospace;">#!/bin/sh</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">yourprogram -options &</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">CMD_PID=$!</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">sleep 300</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">kill $CMD_PID </span><br><br><div class="gmail_quote">This will prevent "yourprogram" from running more than 5 minutes per invocation.<br><br>For C programs, you can use signal(SIGALRM, ...) and alarm(300) to make the program terminate after a while.<br>
<br><span style="font-family: courier new,monospace;">int main(void) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  signal(SIGALRM, shutdown);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  alarm(300);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">void shutdown() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  exit();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">But you say it is compiled and it is called from web pages.<br><br>
Please provide more specifics and I/we will try to see what more can be done.<br><br>On Sat, Jan 23, 2010 at 4:13 PM, Insurance Squared Inc. <span dir="ltr"><<a href="mailto:gcooke@insurancesquared.com" target="_blank">gcooke@insurancesquared.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I've got a compiled script running on my webserver that runs alot, called by various webpages.<br>
<br>
Once in a while it seems like the script doesn't stop running; it keeps on running and chewing up huge amounts of cpu.  So after a couple of days, I end up with 2 or 3 instances of that script running on the server continually.  running 'top' will show 0% idle cpu, with all the cpu being consumed by that script (with an owner of apache).  Kill the pids, everything performs nice again...for a little while.<br>


<br>
Meantime, thousands of other executions of the script perform properly - they execute for a brief second, spit out their numbers, then die gracefully.<br>
<br>
How would one diagnose or stop this sporadic rogue behavior?<br>
<br>
<br>
<br>
_______________________________________________<br>
<a href="http://kwlug-disc_kwlug.org" target="_blank">kwlug-disc_kwlug.org</a> mailing list<br>
<a href="http://kwlug-disc_kwlug.org" target="_blank">kwlug-disc_kwlug.org</a>@<a href="http://kwlug.org" target="_blank">kwlug.org</a><br>
<a href="http://astoria.ccjclearline.com/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://astoria.ccjclearline.com/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com" target="_blank">2bits.com</a>, Inc.<br><a href="http://2bits.com" target="_blank">http://2bits.com</a><br>Drupal optimization, development, customization and consulting.<br>

Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra<br>Simplicity is the ultimate sophistication. --   Leonardo da Vinci<br>