Home > php教程 > php手册 > body text

在WINDOWS中设置计划任务执行PHP文件的方法

WBOY
Release: 2016-06-06 20:39:26
Original
896 people have browsed it

在网上找了些WINDOWS执行PHP的计划任务的方法,有一个写得很全,可惜在我这竟然没通过。最后不得不综合各门派的方法,才能在我这运行成功

1、写一个PHP程序,命名为test.php,内容如下所示:
代码如下:

$fp = fopen("test.txt", "a+");
fwrite($fp, date("Y-m-d H:i:s") . " 成功成功了!\n");
fclose($fp);
?>

程序大胆地写,什么include\require尽管用,都没问题
2、新建Bat文件,命名为test.bat,内容如下所示:
代码如下:
D:\php\php.exe -q D:\website\test.php
//相应目录自己改上

3、建立WINDOWS计划任务:
开始–>控制面板–>任务计划–>添加任务计划
浏览文件夹选择上面的bat文件
设置时间和密码(登陆WINDOWS的)
保存即可了。
4、over! 可以右键计划任务点“运行”试试
Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!