Home > php教程 > php手册 > php 这样写日志 sleep你会了吗?

php 这样写日志 sleep你会了吗?

WBOY
Release: 2016-06-13 09:37:30
Original
1149 people have browsed it


sleep.php

ignore_user_abort(); //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行.
set_time_limit(0); // 执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无限制的执行下去
$interval=10; // 每隔10秒运行
do{
include('cron-config.php'); // 引入文件
if($cron_config['run']=="false") break; // 如果$cron_config['run']为false,就跳出循环,执行下面的语句 echo "跳出循环";
$fp = fopen('test.txt','a');
fwrite($fp,'test');
fclose($fp);
sleep($interval); // 等待10秒
}while(true);
echo "跳出循环";

?>

cron-config.php

$cron_config['run']="true";
?>



Related labels:
log
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template