Using Curl/Post to execute a HTTP request
Well, I didn't take the time to test my snippets, but here are two suggestions...

#1 (preferred) - Bundle all of your input data into a single array, then pass it to your receiving url with a single curl call.  It is best practice to minimize total calls (avoid iterated calls) so long as the operation works for your project, of course.  This avoids sleepy time too.

$ch = curl_init();
$fields = [
    ['input1' =&gt; 'variable1', 'input2' =&gt; 'variable2'],
    ['input1' =&gt; 'variable3', 'input2' =&gt; 'variable4']
];
$COOKIE_FILE_PATH = "/tmp/cookiescron.txt";  // this doesn't appear to be used
$options = [
    CURLOPT_URL               =&gt; 'http://127.0.0.1/index.php',
    CURLOPT_POST              =&gt; true,  // https://www.php.net/manual/en/function.curl-setopt.php says boolean is expected
    CURLOPT_POSTFIELDS        =&gt; http_build_query($fields),
    CURLOPT_TIMEOUT           =&gt; 2,
    CURLOPT_RETURNTRANSFER    =&gt; false,
    CURLOPT_FORBID_REUSE      =&gt; true,
    CURLOPT_CONNECTTIMEOUT    =&gt; 2,
    CURLOPT_DNS_CACHE_TIMEOUT =&gt; 10,
    CURLOPT_FRESH_CONNECT     =&gt; true,
    CURLOPT_HTTPHEADER        =&gt; ['Connection: close']
];
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);




#2 - If your requirements obligate the use of iterated curl calls, I'd recommend only updating the CURLOPT_POSTFIELDS value within the loop.  (Again, not tested)

$ch = curl_init();
$fields = [
    ['input1' =&gt; 'variable1', 'input2' =&gt; 'variable2'],
    ['input1' =&gt; 'variable3', 'input2' =&gt; 'variable4']
];
$COOKIE_FILE_PATH = "/tmp/cookiescron.txt";  // this doesn't appear to be used
$options = [
    CURLOPT_URL               =&gt; 'http://127.0.0.1/index.php',
    CURLOPT_POST              =&gt; true,  // https://www.php.net/manual/en/function.curl-setopt.php says boolean is expected
    CURLOPT_TIMEOUT           =&gt; 2,
    CURLOPT_RETURNTRANSFER    =&gt; false,
    CURLOPT_CONNECTTIMEOUT    =&gt; 2,
    CURLOPT_DNS_CACHE_TIMEOUT =&gt; 10,
];
foreach ($fields as $data) {
    $options[CURLOPT_POSTFIELDS =&gt; http_build_query($data)]; // overwrites previous data
    curl_setopt_array($ch, $options);
    curl_exec($ch);
    sleep(25);
}
curl_close($ch);


The takeaway here is to always try to leave as many processes as possible OUTSIDE of the loop to reduce calls/workload.

Relevant documentation:


https://www.php.net/manual/en/function.curl-setopt.php
https://www.php.net/manual/en/function.curl-setopt-array.php