安装
shell> apt-get install parallel
查看帮助
shell> man parallel_tutorial
添加 PHP 脚本
# /tmp/curl.php
<?php
sleep(3);
echo 1, PHP_EOL;
添加并发执行脚本
# /tmp/mycurl.sh
mycurl() {
START=$(date +%s)
/usr/bin/php /tmp/curl.php
END=$(date +%s)
DIFF=$(( $END - $START ))
echo "It took $DIFF seconds"
}
export -f mycurl
seq 10 | parallel -j0 mycurl
10个并发执行该 PHP 脚本
shell> bash /tmp/mycurl.sh