[CentOS] Timeout for a script
Ian Blackwell
ian at ikel.id.au
Wed Nov 12 10:13:37 UTC 2008
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
More information about the CentOS
mailing list