thinkphp php file php automatically execute PHP file at timed execution

Source: Internet
Author: User

Recently developed SMS task and SMS Send function, with the timing of the implementation of PHP this aspect: to share with you:

(personal notes, write bad, Haihan Haihan, read words can leave a message, but I generally can reply in a timely manner, other online has a lot of such tutorials, everyone a search on the ground)I use the thinkphp development program, the program has been developed, the program has a batch of time to send the function, every once in a while to find the database, and then the matching conditions of the SMS task to send out, the idea is as follows: through the "task" function of win to execute a bat file regularly, BAT file calls the Php.exe file, Php.exe can pass parameters specifying which class and method method to execute as follows: One, thinkphp turn on CLI support1, TP support CLI Command mode exactly, the path of the manual is 13.7.4if the other framework does not support the CLI, then only write the program directly, in fact, is to write the most basic process-oriented PHP code. 2, open the command under the entrance file, add a sentencedefine (' Mode_name ', ' CLI ');The website generally also has the module which can be accessed through the webpage, so can create a new CLI entrance such as index_cli.php, so that other modules can also enter through the normal entrance. Some manuals written on the start CLI are defined by define (' think_mode ', ' CLI '), and may be different versions, note this. ii. New BAT file creationCreate a new TXT file with the following three lines of content:D:CD D:\workspace\dzx2Php.exe D:\workspace\dzx2\index_cli.php sms/sendjob>c:\smslog.txtThis is: The current directory is moved to the D drive, the current directory is moved to the D:\workspace\dzx2 folder (my project portal file), the absolute path of the Php.exe space to enter the absolutely project CLI entry file, the following space + Parameter (I have added php.exe to the path variable of the system's environment variable, so only Php.exe is written) Simple is: The current directory moved to the project portal file, the absolute path of the php.exe+ absolute path of the project portal file + parameters txt file to the bat suffix executable file, click Test to see if the method is executed(You can write in the bat file at the end of a Pause, to see if the error, or directly write " >c:\smslog.txt " bar output to import into a TXT file, run after the file to see the error or report what errors) Iii. New TasksWin under the Control Panel--"Management Program-" Task Scheduler right-click Task Scheduler Library-"New task run account must have permission trigger-" new selection frequency and other functions operation-"New Select startup program below to find their own write the bat file the others can see for themselves after the establishment of the task, the point process Run a bit, see the running time and the results of your own program did not do, the error note is to include the selected user rights, the correct path, and the correct programSo the general thing to do is to ensure that the program runs OK through the URL address, then, click the Bat file program to run OK, then the task is scheduled to run OK

Reference Address:

thinkphp php file php automatically execute PHP file at timed execution

Http://blog.sina.com.cn/s/blog_4acbd39c01011sme.html

thinkphp php file php automatically execute PHP file at timed execution

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.