in reply to Limiting script cpu time

Proc::NiceSleep on CPAN will give you access to nice. However nice doesn't actually limit how much CPU time the process uses but more how much priority the process gets related to others.

What this means is that if there's nothing else running on the system then your niced process will still use as much CPU time. If something else is running though it your process will get a lower priority for CPU time. This may or may not be what you want.

And it should be noted that arguments to nice aren't consistent from unix to unix so check your system's manpages for information.

Caveat: I've not used the module myself.

There's also Apache::LoadAvgLimit which you might be able to borrow code from although that just looks like a similar solution to the check system load and sleep if it's too high solution proposed above. It doesn't stop the script hammering the CPU in between each sleep so it's probably not as useful a solution as nice.

Struan

Replies are listed 'Best First'.
Re: Re: Limiting script cpu time
by Anonymous Monk on Jun 10, 2003 at 05:06 UTC
    FreeBSD also has builtin support for per user process memory limiting, etc. The configuration for this system is stored in /etc/login.conf