Movatterモバイル変換


[0]ホーム

URL:


everything curl

    Retry

    Normally curl only makes a single attempt to perform a transfer and returns anerror if not successful. Using the--retry option you can tell curl to retrycertain failed transfers.

    If a transient error is returned when curl tries to perform a transfer, itretries this number of times before giving up. Setting the number to 0 makescurl do no retries (which is the default). Transient error means either: atimeout, an FTP 4xx response code or an HTTP 408, 429, 500, 502, 503 or 504response code.

    Tweak your retries

    When curl is about to retry a transfer, it first waits one second and then forall forthcoming retries it doubles the waiting time until it reaches 10minutes which then is the delay between the rest of the retries. Using--retry-delay you can disable this exponential backoff algorithm and setyour own delay between the attempts. With--retry-max-time you cap the totaltime allowed for retries. The--max-time option still specifies the longesttime a single of these transfers is allowed to spend.

    Make curl retry up to 5 times, but no more than two minutes:

    curl --retry 5 --retry-max-time 120 https://example.com

    Connection refused

    The default retry mechanism only retries transfers for what are consideredtransient errors. Those are errors that the server itself hints and qualifiesas being there right now but that might be gone at a later time.

    Sometimes you as a user know more about the situation and you can then helpout curl to do better retries. For starters, you can tell curl to consider"connection refused" to be a transient error. Maybe you know that the serveryou communicate with is a flaky one or maybe you know that you sometimes tryto download from it when it reboots or similar. You use--retry-connrefusedfor this.

    For example: retry up to 5 times and considerECONNREFUSED a reason forretry:

    curl --retry 5 --retry-connrefused https://example.com

    Retry on any and all errors

    The most aggressive form of retry is for the cases where youknow that theURL is supposed to work and you do not tolerate any failures. Using--retry-all-errors makes curl treat all transfers failures as reason forretry.

    For example: retry up to 12 times for all errors:

    curl --retry 12 --retry-all-errors https://example.com

    [8]ページ先頭

    ©2009-2025 Movatter.jp