On 2007-04-07, Shawn Everett shawn@tandac.com wrote:
Just building off Micheal's idea:
killafter.sh <command> <time> #!/bin/bash
$1 & pid=$! sleep $2 kill -TERM $pid
Just in case it might have died an recycled the pid, refer to the job (%1), not the pid:
killafter.sh <command> <time> #!bin/bash $1 & sleep $2 kill -TERM %1
Another way of doing it might be to fork a sub-shell with limits:
(ulimit -t 1 ; top)
But this is cputime, not walltime...
-jf