使用curl时,有两个超时时间:一个是连接超时时间,另一个是数据传输的最大允许时间。

 

连接超时时间: --connect-timeout 

    例:

    curl --connect-timeout 1 "http://localhost/index.html"

    出错提示形如:

    curl: (28) connect() timed out!

    

    不能连接提示如:

    curl:(7) couldn't connect to host


数据传输的最大允许时间用: -m 

    例:

    curl --connect-timeout 1 -m 20 "http://localhost/index.html"

    

    数据传输的最大允许时间超时的话,出错提示形如:

    curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received

    
用途:

    可用在判断某资源是否可以访问,例如lvs的健康状态监测