[CentOS] Re: command to ensure other command does last longer than5 seconds
Jan-Frode Myklebust
mykleb at no.ibm.com
Sat Apr 7 08:30:10 UTC 2007
On 2007-04-07, Shawn Everett <shawn at 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
--
email/jabber: janfrode at tanso.net
Web: http://tanso.net
More information about the CentOS
mailing list