一,http請求超時時間
可能出現的場景:
1,curl進程運行了一個世紀還木結束,curl的時候設置了超時時間 --connect-timeout 1000
2,operation timed out after 1000 milliseconds with 0 bytes received
3,connect() timed out!
wget對超時時間, 是有分階段的, 比如說請求的超時, 傳輸的超時,同樣HTTP請求有兩個超時時間:一個是連接超時時間,另一個是數據傳輸的最大允許時間,出現問題就要看是哪個超時時間出問題了。
curl命令行
連接超時時間用 --connect-timeout 參數來指定,數據傳輸的最大允許時間用 -m 參數來指定,時間是毫秒
例如:
curl --connect-timeout 10 -m 20 "http://***"
連接超時的話,出錯提示形如:
curl: (28) connect() timed out!
數據傳輸的最大允許時間超時的話,出錯提示形如:
curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received
使用PHP的curl_init
當我們執行后,每隔5秒鍾,我們會得到一行 Hello World ,如果不按停止按鈕,瀏覽器會不停的一行一行繼續加載。
通過這一方法,我們可以完成很多功能,例如機器人爬蟲、即時留言板等程序。
如果要停止運行只能重啟php-fpm:
查看php-fpm進程數:
ps aux | grep -c php-fpm
查看運行內存
/usr/bin/php -i|grep mem
重啟php-fpm
/etc/init.d/php-fpm restart
原文鏈接:https://www.cnblogs.com/doseoer/p/6943495.html