Home > Article > Backend Development > Do you know how to write logs in php like sleep? _PHP Tutorial
sleep.php
ignore_user_abort(); //Even if the Client is disconnected (such as closing the browser), the PHP script can continue to execute.
set_time_limit(0); // The execution time is unlimited. The default execution time of PHP is 30 seconds. Through set_time_limit(0), the program can be executed without limit
$interval=10; // Run every 10 seconds
do{
include('cron-config.php'); //Introduce files
if($cron_config['run']=="false") break; // If $cron_config['run'] is false, break out of the loop and execute the following statement echo "break out of the loop";
$fp = fopen('test.txt','a');
fwrite($fp,'test');
fclose($fp);
sleep($interval); // Wait 10 seconds
}while(true);
echo "break out of loop";
?>
cron-config.php
$cron_config['run']="true";
?>