php 设置curl不超时时间,curl命令的超时时间
今天在一臺服務器上突然看到一個curl進程已經運行了28天還木結束, 有點奇怪! 我在使用curl的時候也設置了超時時間, --connect-timeout 5
curl --connect-timeout 5 --data-binary "set=${L_UPLOAD_DATA_ENCODED}"?http://172.88.99.00:8080/xxx.php?&>/dev/null
按理來說, 應該是5s就會超時退出了!? 納悶之余想起wget好像對超時時間, 是有分階段的, 比如說請求的超時, 傳輸的超時等等, 所以就仔細查看了下curl的手冊頁:
原來使用curl時,有兩個超時時間:一個是連接超時時間,另一個是整個過程允許的最大時間,
--connect-timeout
Maximum time in seconds that you allow the connection to the server to take.? This only limits the connection phase, once curl has connected this option is of no more use. See also the -m/--max-time option.
If this option is used several times, the last one will be used.
這個是指定連接超時時間。 如果出錯, 提示形如:curl: (28) connect() timed out!
-m/--max-time
Maximum? time? in seconds that you allow the whole operation to take.? This is useful for preventing your batch jobs from hanging for hours due to slow networks or links going down.? See also the --connect-timeout option.
If this option is used several times, the last one will be used.
這個是指定整個過程最大的允許時間。 出錯提示如:curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received
還可以這樣用: curl -o x.log "http://www.yyyy.com" --speed-time 5 --speed-limit 1
是說將url內容保存到x.log中, 如果傳輸速度小于1字節(jié)/秒的狀態(tài)持續(xù)5秒,該連接就會終止.
總結
以上是生活随笔為你收集整理的php 设置curl不超时时间,curl命令的超时时间的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab 柱面投影,matlab练习
- 下一篇: php扩展的xdebug,安装php扩展