Use bat on Windows Server to regularly execute php

Source: Internet
Author: User
: This article describes how to use bat to regularly execute php on a Windows Server. For more information about PHP tutorials, see. Use bat on Windows Server to regularly execute php

There is a similar cmd and bat file on windows and linux. bat files are similar to shell files. executing this bat file is equivalent to executing the commands in sequence (of course, you can also implement programming through logic). Therefore, we can use the bat command file to implement PHP scheduled tasks on windows servers. In fact, scheduled tasks on windows are the same as those on linux, except that the methods and approaches are different. Now let's start.

First, create a cron. bat file in a location that you think is appropriate, and then open it in a text editor (Notepad can be used). write the following content in it:

D: \ php \ php.exe-q D: \ website \ test. php

In this sentence, php.exe is used to execute the php file test. php. like the contab above, it bypasses the server environment and the execution efficiency is relatively high. Click save to close the editor.

Next, set a scheduled task to run cron. bat. Choose Start> Control Panel> task plan> add task plan. on the displayed page, set the time and password of the scheduled task, and select cron. attach bat. OK, so that a scheduled task is created. right-click the scheduled task and run it. the scheduled task starts to run. when it reaches the point, it runs cron. bat processing, cron. bat then executes php.

The above introduces the use of bat on Windows Server to regularly execute php, including some content, hope to be helpful to friends who are interested in PHP tutorials.

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.