Bash timeout function

TIMEOUT=”60″
$MYPROGRAM >/dev/null &
pid=$!
sleep $TIMEOUT && kill -9 $pid >/dev/null 2>&1 && echo “$MYPROGRAM failed”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.