Thinkphp regularly executes the php file windows System Task plan implementation ideas are as follows:
A batfile is executed at a time using the winmtr task execution function. the php.exefile is used in the batfile. php.exe can pass parameters to specify the class and method to be executed.
The method is as follows:
1. enable cli support for thinkphp
1. tp supports cli command mode. the path of the manual is 13.7.4.
If other frameworks used do not support cli, you can only write programs directly. In fact, it is the most basic php code for process-oriented writing.
2. open the command in the entry file and add a sentence
Define ('mode _ name', 'cli ');
Websites generally have modules that can be accessed through web pages. Therefore, you can create a cli entry, such as index_cli.php, so that other modules can be accessed through the normal Portal. In some manuals, the cli defines define ('think_mode ', 'cli'). It may be of different versions. pay attention to this.
II. create a new bat file
Create a txt file with the following three lines:
D:
Cd D: \ workspace \ dzx2
Php.exe D: \ workspace \ dzx2 \ index_cli.php Sms/sendjob> c: \ smslog.txt
This means that the current directory is moved to the D drive, and the current directory is moved to the D: \ workspace \ dzx2folder (my project access file is complete, and php.exe cute is used)
Simply put: When the project directory is moved to the project access file, the php.exe + project entry file + parameters in the absolute path are obtained.
Change the txt file to an executable file with the bat suffix and click test whether the execution method is correct.
(You can write a Pause at the end of the bat file to see if an error is reported, or directly write the output content of "> c: \ smslog.txt" to a txt file, view the file after running to check whether an error is reported or not)
3. create a task
Is the control panel under win? Hypervisor? Task Scheduler
Right-click the Task Scheduler Library and choose create task.
The running account must have the permission
Trigger-new selection frequency and other functions
Operation-create and select a startup program find the bat file you have written below
Others can be viewed by yourself
After the task is created, click "run" to run the program. check whether the running time and result of the task have been completed by the program,
If there is a mistake, note that it containsThe selected user permissions, the paths are correct, and the programs are correct.
So generally, first, ensure that the program runs OK by accessing the url address, then click the bat file to run the program OK, and then run the task plan OK.