Php: Set the scheduled task execution 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 to make the operation successful. 1. write a PHP program named test. php. the content is as follows: [php] & lt ;? Php $ fp =... "/> <scripttype =" text/javascript "s

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 to make the operation successful.

1. write a PHP program named test. php. the content is as follows:


[Php]
$ Fp = fopen ("test.txt", "a + ");
Fwrite ($ fp, date ("Y-m-d H: I: s"). "success! \ N ");
Fclose ($ fp );
?>

$ Fp = fopen ("test.txt", "a + ");
Fwrite ($ fp, date ("Y-m-d H: I: s"). "success! \ N ");
Fclose ($ fp );
?> The program writes it boldly. it is okay to use include \ require.


2. create a Bat file named test. bat. the content is as follows:
D: \ php \ php.exe-q D: \ website \ test. php // change the directory to the correct one.

 


3. create a WINDOWS scheduled task:
Start C> Control Panel C> task Plan C> add task plan
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 running process is omitted ............

There is a small problem with the above method. when a task is scheduled to run, the dos window will appear on the windows desktop. here, make some modifications. You can use the vbs method to achieve this without the black dos window. The code is as follows:

DIM objShell
Set objShell = wscript. createObject ("wscript. shell ")
Ireturn = objShell. Run ("C: \ php \ php.exe d: \ www \ timer. php", 0, TRUE)

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

 


 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.