Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can i limit the maxuim ammount of CPU that perl scripts in specific directory can use ?
does it have something to do with Apache ? any ideas ?
running on :
NOTE : mod_perl is not installed and cant be installed due to conflicts with "cPanel" control panel And
Yes its shared Server and there's other users suffering from CPU load

Replies are listed 'Best First'.
Re: CPU Limitation
by sh1tn (Priest) on Jun 11, 2006 at 13:41 UTC
    This is not Perl issue; nevertheless take a look at tlpd.org books and especially the chapter Linux Limiting and Monitoring Users. You have to modify limits.conf in /etc/security according to your needs.


Re: CPU Limitation
by sgifford (Prior) on Jun 11, 2006 at 15:50 UTC
    setpriority will let you set the priority of your script relative to others, though it doesn't set a hard limit. BSD::Resource will let you set a total amount of CPU time a script can be used before it is killed.

    There's not an easy way to do this automatically for all scripts in a directory, but you could certainly create a module that set these limits appropriately, then just use that module from any script to which the limits should apply.