我确实有这个脚本来让一些变量访问服务器。关键是这样做很慢,我必须多次运行相同的脚本才能获得合适的请求率。如何在无需运行 4 或 5 次的情况下使用此 curl 脚本增加线程数?
我也想让它更快,性能更好,这是原创的
while ! grep "TokenException" output.txt > /dev/null
do
echo -e '\n'$(date +%x_%H:%M:%S:%3N) > output.txt
curl -s -H 'Host: host.com' -H "Cookie: session-token="$SESSION\" -H "x-amz-access-token: $token" -H "x-flex-instance-id: $flex" -H 'Accept: */*' -H 'User-Agent: Dalvik/2.1.0 (Linux; U; Android 7.1.1; Nexus 5X Build/N4F26T) RabbitAndroid/3.0.6778.0' -H 'Accept-Language: en-us' --compressed 'https://hostname.com/GetOffersForProvider?serviceAreaIds=16' >> output.txt
if grep -q "OFFERED" output.txt; then
cat output.txt >> foundb.txt
./getlast.bat
if [ ! -f pageflag.txt ]; then
/usr/bin/php alert.php
echo "paged" > pageflag.txt
fi
sleep 0.05
fi
done
我修改为
while ! grep "TokenException" output.txt > /dev/null
do
echo -e '\n'$(date +%x_%H:%M:%S:%3N) > output.txt
curl -s -H 'Host: host.com' -H "Cookie: session-token="$SESSION\" -H "x-amz-access-token: $token" -H "x-flex-instance-id: $flex" -H 'Accept: */*' -H 'User-Agent: Dalvik/2.1.0 (Linux; U; Android 7.1.1; Nexus 5X Build/N4F26T) RabbitAndroid/3.0.6778.0' -H 'Accept-Language: en-us' --compressed 'https://hostname.com/GetOffersForProvider?serviceAreaIds=16' >> output.txt
if grep -q "OFFERED" output.txt; then
cat output.txt >> foundb.txt
./getlast.bat
/usr/bin/php alert.php
sleep 0.05
fi
done
一些关于在多线程上运行并且即使在 sleep 状态下运行速度更快的建议,或者其他暂停毫秒的方法?重点是它应该用从curl捕获的变量尽快执行./getlast.bat,但是它在数据和getlast.bat执行之间有2秒的时间差,太多了
最佳答案
curl
本身不支持多连接/线程和/或恢复已取消/停止的操作。
使用aria2或类似的东西。
关于linux - 如何加快此 curl 脚本并更快地响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48676499/