doujin4031 2017-03-29 08:16
浏览 1452

同时执行多个shell_exec()命令?

Hi so i am wondering if somebody can offer me a solution..

I have multiple instances of a php script i would like to run at once, I can semi achieve this using shell_exec() and not waiting for a response apart from the pid. This works wonderfully. However when doing this with the method below it works well for 100 or so executes but I need it to execute around 1000 times and it is taking too long to loop around the foreach and execute 1 by one.

Example:

 $items = $array(daatabase entries);

   foreach($items as $i){
    $pid = shell_exec("execute the process.php");
   }

Now assuming there are < 100 this will take around 1 second or so to exec which is OK however i need to run loads of these and this will take 10-20 seconds.

Is there any way of sending the commands in bulk rather than 1 at a time?

Thanks

  • 写回答

2条回答 默认 最新

  • doulai2573 2017-03-29 08:24
    关注

    Something like pthreads perhaps?

    https://www.sitepoint.com/parallel-programming-pthreads-php-fundamentals/ (The most recent result I could find)

    评论

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算