Home > Backend Development > PHP Tutorial > php: Set up scheduled tasks to execute PHP files in WINDOWS_PHP tutorial

php: Set up scheduled tasks to execute PHP files in WINDOWS_PHP tutorial

WBOY
Release: 2016-07-14 10:10:41
Original
1025 people have browsed it

I looked for some methods on the Internet to execute PHP scheduled tasks in Windows, and one of them was very comprehensive, but unfortunately it didn’t pass in my case. In the end, I had to combine the methods of various sects to successfully operate it here.

1. Write a PHP program, named test.php, with the following content:


[php]
$fp = fopen("test.txt", "a+");
fwrite($fp, date("Y-m-d H:i:s") . " Success succeeded! n");
fclose($fp);
?>

$fp = fopen("test.txt", "a+");
fwrite($fp, date("Y-m-d H:i:s") . " Success succeeded! n");
fclose($fp);
?>Write the program boldly and use any includerequire, no problem.


​​ 2. Create a new Bat file: named test.bat, the content is as follows:
D:phpphp.exe -q D:websitetest.php //Change the corresponding directory yourself


3. Create WINDOWS scheduled tasks:
StartC>Control PanelC>Task ScheduleC>Add Task Schedule
Browse the folder and select the bat file above
Set time and password (log in to WINDOWS)
Just save it.

4. Over! You can right-click the scheduled task and click "Run" to try

The running process is omitted…………

There is a small problem with the above method. When the scheduled task is running, a dos window will appear on the Windows desktop. Please make some modifications here. Just use vbs to achieve it, and the black dos window will not appear. The code is as follows:

DIM objShell
set objShell=wscript.createObject("wscript.shell")
Ireturn=objShell.Run("C:phpphp.exe d:wwwtimer.php",0,TRUE)

Save it as a .vbs file and replace the original .bat file.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477499.htmlTechArticleI looked for some methods on the Internet to execute PHP scheduled tasks on Windows, and one of them was very comprehensive, but unfortunately in my This actually failed. In the end, I had to combine the methods of various sects to make it work for me...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template