Tugger the SLUGger!SLUG Mailing List Archives

Re: [chat] Killing run away scripts


On Sun, Oct 28, 2001 at 04:28:56PM +1100, Ken Foskey wrote:
 
> What I was thinking is how I can register a kill command after a couple 
> of hours.   This whole process takes minutes and if it is hours then it 
> has screwed up.   Is there anyway of doing this portably between unices.

You could stick this in your shell scripts.
ulimit -t 3600

Don't know if its portable, or even if its a good idea, but the script and 
any processes it spawns should die after they've used 3600 seconds of cpu time. 

Depending on how hard the process is hitting the cpu, it could take years to
hit 3600 seconds of cpu time, or if its in a tight loop it could take a little 
over an hour.

$ ulimit -t 60
$ time echo "while : ; do : ; done" | sh -s
Killed

real	1m10.814s
user	0m58.520s
sys	0m2.490s


-- 
	chesty