Re: command to ensure other command does last longer than5 seconds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 2007-04-07, Shawn Everett <shawn@xxxxxxxxxx> 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@xxxxxxxxx
Web:            http://tanso.net

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux