Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8124857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:36:22+00:00 2026-06-06T06:36:22+00:00

What I need to do is process multiple requests that are pending in a

  • 0

What I need to do is process multiple requests that are pending in a database, using PHP.

What I’m currently trying to do is:
When my cronjob runs. I want to call a file “process_a.php” 10 times, instantly, without waiting for it to finish processing (process_a.php could take a few minutes).

I tried to do this using CURL. But right when my cronjob calls process_a.php, it waits for it to finish processing and return before calling another process_a.php file.

I even tried putting code in process_a.php to close the connection instantly, then continue processing in the background. but the cronjob still waited for it to finish.

I just want the same file being executed 10 times at once, you know, like if 10 different users were to request the index.php page of my website…
Any ideas!?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:36:24+00:00Added an answer on June 6, 2026 at 6:36 am

    As told by @Brad curl-multi-exec should be an option.

    http://php.net/manual/en/function.curl-multi-exec.php

        <?php
    //create the multiple cURL handle
    $mh = curl_multi_init();
    
    // create both cURL resources
    for($i = 0; $i < 10;$i++){
         $ch[$i] = curl_init();
         curl_setopt($ch[$i], CURLOPT_URL, "http://urhost//path/to/process_a.php");
         curl_setopt($ch[$i], CURLOPT_HEADER, 0);
         curl_multi_add_handle($mh,$ch[$i]);//add the handles
    }
    
    $active = null;
    
    //execute the handles
    do {
        $mrc = curl_multi_exec($mh, $active);
    } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    
    while ($active && $mrc == CURLM_OK) {
        if (curl_multi_select($mh) != -1) {
            do {
                $mrc = curl_multi_exec($mh, $active);
            } while ($mrc == CURLM_CALL_MULTI_PERFORM);
        }
    }
    
    //close the handles
    for($i = 0; $i < 10;$i++){
         curl_multi_remove_handle($mh, $ch[$i]);
    }
    curl_multi_close($mh);
    
    ?>
    

    I tested this script by calling another script below :

    <?php 
    print microtime();//Return current Unix timestamp with microseconds 
    print '<br>';
    ?>
    

    and here are the results, each handle differing by microseconds in execution time.

    0.27085300 1340214659
    0.44853600 1340214659
    0.46611800 1340214659
    0.48201000 1340214659
    0.50209400 1340214659
    0.48233900 1340214659
    0.52274300 1340214659
    0.54757800 1340214659
    0.57316900 1340214659
    0.59475800 1340214659
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to issue multiple $.get requests, process their responses, and record the results
I have a method that I call to make web service requests using GET.
I need to make the session readonly so I can establish multiple requests to
The task is - need to process multiple I/O streams (HTTP downloads) with some
I am in the process of writing a web-app that uses multiple web APIs.
Scenario: Data is received and written to database with timestamps. I need to process
I'm using curl_multi functions to request multiple URLs and process them as they complete.
I am making an application where I need to invoke requests in multiple view
I am having a situation where i need multiple connection strings to process a
I need to imlement in cocoa, a design that relies on multiple threads. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.