A
A
Azat Kiberov2019-04-09 20:03:18
Task Schedulers
Azat Kiberov, 2019-04-09 20:03:18

Cron does not start using an external service, how to fix it?

Faced a problem.
You need to run a php file that sends certain data to another site.
script.php file.
Inside the code

$ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_ENCODING, ""); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
        curl_setopt($ch, CURLOPT_POSTFIELDS, array(
            'urlsite' => $url,
            'text' => $text,
            'Button' => 'get'
        ));
        curl_setopt($ch, CURLOPT_USERAGENT, 'MSIE 5');
        curl_setopt($ch, CURLOPT_REFERER, $referer);
        curl_setopt($ch, CURLOPT_TIMEOUT, 2);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 

        $res = curl_exec($ch);
    
        if (!$res)
        {
            $error = curl_error($ch) . '(' . curl_errno($ch) . ')<br>';
            echo $error;

        }
        curl_close($ch);

I found this external cron https://cron-job.org/ . Signed up.
Created cron is created using a regular link like so https://site/script.php .
Then I created it for 5 minutes .. I waited and looked and there no data was sent.
What can be wrong.
When I run this script via browser like this https://site/script.php enter the data is sent via cron no.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question