Home  >  Article  >  Backend Development  >  Do you know how to write logs in php like sleep? _PHP Tutorial

Do you know how to write logs in php like sleep? _PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:32:161040browse


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";
?>



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/755795.htmlTechArticlesleep.php ignore_user_abort(); //Even if the Client is disconnected (such as closing the browser), the PHP script will You can continue to execute. set_time_limit(0); // The execution time is unlimited. The default execution time of PHP is...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn