How to set a scheduled task to execute a php file in WINDOWS
Source: Internet
Author: User
I found some methods on the Internet to execute PHP scheduled tasks in WINDOWS. one of them was completely written, but unfortunately I did not pass it. Finally, I had to combine the methods of various schools in order to run successfully here. 1. write a PHP program named test. php. the content is as follows:
The code is as follows:
$ Fp = fopen ("test.txt", "a + ");
Fwrite ($ fp, date ("Y-m-d H: I: s"). "success! \ N ");
Fclose ($ fp );
?>
The program writes it boldly. it's okay to use include \ require.
2. create a Bat file named test. bat. the content is as follows:
The code is as follows:
D: \ php \ php.exe-q D: \ website \ test. php
// Change the Directory
3. create a WINDOWS scheduled task:
Start> Control Panel> Task Scheduler> Add Task Scheduler
Browse the folder and select the above bat file
Set the time and password (for WINDOWS login)
Save it.
4. over! Right-click the scheduled task and click "run ".
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.