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 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题