Skip to content

Latest commit

 

History

History
49 lines (35 loc) · 737 Bytes

parallel.md

File metadata and controls

49 lines (35 loc) · 737 Bytes

安装

安装

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