Answer the question
In order to leave comments, you need to log in
How to optimize php(CRON) code?
We have a website hosted by TimeWeb and we received messages not long ago
Dear Customer!
Our specialists recorded a high load on the server when executing the script *******/myCron.php.
We were forced to remove the rights to the file, in order for it not to run, please optimize the work of this script to reduce the generated load.
function cron()
{
$url = "https://royal.nurshifo.ru/cron.php";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query(""));
$res = curl_exec($ch);
if(curl_error($ch))
{
var_dump(curl_error($ch));
}
else
{
return json_decode($res);
}
}
echo "s";
for($i=0 ; $i<20 ; $i++){
cron();
sleep(3);
}
Answer the question
In order to leave comments, you need to log in
Take the UPU, and no one will write such messages.
this script does not look like some problematic one, it just constantly hangs in work, maybe that's why they don't like it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question