Skip to content

Instantly share code, notes, and snippets.

@arsatiki
Created April 12, 2012 14:12
Show Gist options
  • Save arsatiki/2367577 to your computer and use it in GitHub Desktop.
Save arsatiki/2367577 to your computer and use it in GitHub Desktop.
A 404 sensitive wrapper around curl
#!/bin/sh
TIMEOUT=45
DELAY=10
RETRIES=6
OUTFILE=/tmp/curlfile.$$
for (( i=0; i < RETRIES; i++ )); do
curl -sf -m $TIMEOUT $1 > $OUTFILE
ERROR=$?
if [ "$ERROR" -eq 0 ]; then
cat $OUTFILE
exit 0
fi
echo Curl error code $ERROR, attempt $i >> /tmp/errors.$$
sleep $DELAY
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment