[win server 2008] Set timed tasks, set .bat files to execute php scripts

In Windows Server 2008, use scheduled tasks to execute BAT bat regularly to execute PHP scripts

1. First perform the task manager settings and execute the .BAT file configuration every 1 minute

First of all, Windows Server 2008 is very different from other server operating systems and Windows Server 2003. The name of the scheduled task is that "Task Scheduler" is not in the control panel, but in "Administrative Tools".

Since the server needs to do some tasks, execute it regularly, write the program yourself, it is troublesome, so BAT is used instead. Many people on the Internet are talking about how to configure it every minute. Today we will configure it.

Open "Task Scheduler" - click "Task Scheduler Library" and you will see "Create Basic Task" and "Create Task" in the action item on the right, as shown in the figure:

Click "Create Task" as shown in the figure: fill in the corresponding name and check the necessary conditions

 

 

 

Select the "Trigger" option, click "New", and create a task execution time. After selecting "Repeated Task Interval", there is a time option later, whether it is an hour or a minute. You can choose it yourself, then modify the time, and then confirm.

 

 

Then configure the [operation] that needs to be performed, which is to select the written program or BAT file. The important configuration here is that after selecting the BAT file, in "Start at (optional)", you must fill in the corresponding execution program or The directory where the BAT file is located, otherwise the execution is unsuccessful.

 

 

After adding, the added scheduled task will appear in the list bar.


 

 

Second, .BAT executes the writing method of PHP script

Create a new Bat file and name it test.bat with the following contents: 

code show as below: 
D:\php\php.exe -q D:\website\test.php 
//Change the corresponding directory by yourself 

 

Our test.php can write the following content for testing:

If the execution is successful, open test.txt in the same directory as test.php, and it should be written [Successful! 】 ~Get it~! !

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325306222&siteId=291194637