Re: Timeout for a script

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



Jussi Hirvi wrote:
> How could I make a script time out after nn minutes, if it's not finished by
> then?
>   
I put this little test script together.  It seems to work OK...
#!/bin/bash
timeoutseconds=5
pid=$$
(echo Will kill $pid in $timeoutseconds seconds; sleep $timeoutseconds;
kill -1 $pid) &
while true
do
  echo Hello
  sleep 0.6
done

You may need to vary the signal in the kill statement, depending on what
you're running.

Ian
_______________________________________________
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