日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 设置curl不超时时间,curl命令的超时时间

發(fā)布時間:2024/4/14 php 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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命令的超时时间的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。