curl にリトライオプションがあるなんんて知らなかったのでここにメモします。
使用例
失敗する場合
$ curl --retry 3 http://sample curl: (6) Could not resolve host: sample Warning: Problem : timeout. Will retry in 1 seconds. 3 retries left. curl: (6) Could not resolve host: sample Warning: Problem : timeout. Will retry in 2 seconds. 2 retries left. curl: (6) Could not resolve host: sample Warning: Problem : timeout. Will retry in 4 seconds. 1 retries left. curl: (6) Could not resolve host: sample
成功する場合
$ curl --retry 3 http://sample.com <html><head><title>sample.com</title></head><body><h1>sample.com</h1><p>Coming soon.</p></body></html>