一、現象
1.查看進程是否存在
ps -ef | grep -v 'grep' |grep -E 'shell/cron/bonus/cash'
www 2624 1 0 Oct24 ? 00:00:35 /usr/local/bin/php /data1/www/htdocs/hb.e.weibo.com/v2/www/htdocs/index.php --uri=shell/cron/bonus/cash --get=proc_num=1&proc_total=1 --post=
2.查看進程建立時間
ps -p 2624 -o lstart
STARTED
Sat Oct 24 22:20:03 2015
3.查看進程的系統調用
strace -p 2624
Process 2624 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 0
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 0 (Timeout)
4.查看fd=5開啟的檔案
lsof -d 5 | grep 2624
php 2624 www 5u IPv4 3876970637 0t0 TCP 10.74.14.199:45473->host-31.alipay.com:https (ESTABLISHED)
二、複現
1. 偵聽107.170.249.52的1234連接埠
nc -l 1234
2.訪問107.170.249.52:1234
curl http://107.170.249.52:1234
3.107.170.249.52接到該請求
4.strace該curl進程
5.與上文所述現象一致
三、解決
法1:
php curl調用時設定逾時
法2:
文/k1ic(簡書作者)
原文連結:http://www.jianshu.com/p/8a247cae629a
著作權歸作者所有,轉載請聯絡作者獲得授權,並標註“簡書作者”。