Timing out lynx request in a bash script

I have a Bash script where, in a loop, I access several urls.

Sometimes, if an url is not available, lynx hangs, and the script does not continue. How can I time out the lynx request when it takes more than, 10 Seconds, but continue with the other jobs...

For some reason lynx does not care if a -connect_timeout=10 is set...

for those who care about a solution for this, you can build this inside you script:

typeset -i w=0
while ps $pid >/dev/null
do
sleep 1
w=$w+1
if [ $w -ge 10 ]
then
kill $pid
break
fi
done

1 Like