php计划任务php中的ignore_user_abort实现计划任务
来源:互联网 发布:哆点 for mac 编辑:程序博客网 时间:2024/04/20 08:59
函数-ignore_user_abort,这个函数可以帮助我们实现像linux中的cron一样实现计划任务,下面一起来看下该如何来实现。
首先看下php手册对这个函数的解释
Description
int ignore_user_abort ([ bool $setting ] )
Sets whether a client disconnect should cause a script to be aborted.
也就是说无论客户端是否关闭浏览器,下面的程序都会执行.
再看下其参数
Parameters
setting
If not set, the function will only return the current setting.
这个函数接受一个参数,来决定是否启用ignore_user_abort的功能。
再看其返回值:
Return Values
Returns the previous setting, as a boolean.
这里说返回前一次的设置,并且是bool值得,经过我的测试,这个说法是不对的,返回的明明是int型的,不相信的话大家可以写一个php文件来测试下。
说了这么多了,到底该如何用php的这个函数实现计划任务呢?还跌借助另外一个函数,这个函数是set_time_limit,通过 set_time_limit0)可以设置程序的执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无 限制的执行下去。在程序执行之前加上ignore_user_abort(1)和set_time_limit(0)即可以了,最终程序该如何写呢?给大 家一个例子。
QUOTE:
ignore_user_abort(); // run script in background
set_time_limit(0); // run script forever
$interval=60*15; // do every 15 minutes...
do{
// add the script that has to be ran every 15 minutes here
// ...
sleep($interval); // wait 15 minutes
}while(true);
?>
首先看下php手册对这个函数的解释
Description
int ignore_user_abort ([ bool $setting ] )
Sets whether a client disconnect should cause a script to be aborted.
也就是说无论客户端是否关闭浏览器,下面的程序都会执行.
再看下其参数
Parameters
setting
If not set, the function will only return the current setting.
这个函数接受一个参数,来决定是否启用ignore_user_abort的功能。
再看其返回值:
Return Values
Returns the previous setting, as a boolean.
这里说返回前一次的设置,并且是bool值得,经过我的测试,这个说法是不对的,返回的明明是int型的,不相信的话大家可以写一个php文件来测试下。
说了这么多了,到底该如何用php的这个函数实现计划任务呢?还跌借助另外一个函数,这个函数是set_time_limit,通过 set_time_limit0)可以设置程序的执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无 限制的执行下去。在程序执行之前加上ignore_user_abort(1)和set_time_limit(0)即可以了,最终程序该如何写呢?给大 家一个例子。
QUOTE:
ignore_user_abort(); // run script in background
set_time_limit(0); // run script forever
$interval=60*15; // do every 15 minutes...
do{
// add the script that has to be ran every 15 minutes here
// ...
sleep($interval); // wait 15 minutes
}while(true);
?>
0 0
- php计划任务php中的ignore_user_abort实现计划任务
- php计划任务php中的ignore_user_abort实现计划任务
- php计划任务php中的ignore_user_abort实现计划任务
- 用php中的ignore_user_abort实现计划任务
- 用 ignore_user_abort函数实现php计划任务
- PHP:ignore_user_abort()+set_time_limit(0)+sleep($interval)实现计划任务
- php ignore_user_abort()实现计划任务功能,实现文件能够在浏览器关掉之后照样运行
- php计划任务的实现
- PHP 计划任务的实现
- php计划任务的实现
- PHP使用任务计划实现定时任务
- PHP执行计划任务
- windows计划任务PHP
- php使用计划任务
- PHP执行计划任务
- php+linux 计划任务
- php 计划任务
- php定时计划任务实现方法
- Python 代码调试技巧
- flume参考手册
- ImageView 使用研究
- WPF学习 第十一章2 触发器
- wcscpy与_tcscpy关系 strcpy_s与strcpy比较
- php计划任务php中的ignore_user_abort实现计划任务
- Java爬虫-WebCollector
- PHP获取客户IP
- Android 中关于activity引起的内存溢出
- MySQL存储过程详解 mysql 存储过程
- laravel 数据迁移与填充的应用总结
- Spring4常用信息笔记-1--JDBC,JDBCTemplate
- cocos2dx项目中应用ttf字体
- Java多线程理解(线程安全)