in reply to Limiting script cpu time

IIRC, you can use the ulimit Unix command to limit cpu time, among other things. Just type man ulimit for more info. Or, for a more perlish solution:
#!perl $SIG{ALARM} = sub {die "Time Out!"}; alarm(120); #this script will run for at most 120 seconds #your script goes here

thor

Replies are listed 'Best First'.
Re: Re: Limiting script cpu time
by aquarium (Curate) on Jun 10, 2003 at 01:46 UTC
    i think he/she's after not taking up too much % cpu time; not to kill the script after it's done half the image. this can be achieved with "nice" unix command. i don't know of a module that can do same from within perl. there is a module kstat which will give you current cpu load for processes, so you could parse that for your process id and do a few waits if high