Background: The project needs to configure a scheduled task to scan the data table data, will be expiring orders marked out, write to the System message reminder table. Previously configured Crontab to execute PHP scripts directly, and then all the way to the process to achieve the end of the business. Recent projects have used the thinkphp framework, thinking that the framework for data manipulation encapsulation convenience, do not want to run the PHP script file alone. However, the controller controller file written in the project, configured to crontab new after the call to the corresponding method is completely ineffective. Toss some time, found not finished, on the resolute give up, think of Linux command wget. It is possible to start configuring wget and setting the address to the address of the controller to be executed. However, it is important to remember that the controller of a task running is best to inherit a base class, and then write the validation section in the thinkphp initial function _initialize of the base class, so as to avoid external access as much as possible ( You can verify that the Access IP is username and pwd in the local or access address.
Above is the description of the business, the following directly on the code
* * * * * root wget-t 1-t 0-q--spider "Http://localhost/tptest/index.php?c=timetask&a=get_sys_warm&visit_name =123456&visit_pwd=123456 "
There are several parameters for the wget command:
-T: Number of connections (reconnection after failure)
-T: Connection time settings (0 does not timeout)
-Q: Quiet mode (no message output)
--spider: Do not download any information
Note: A bit of a problem is that this belongs to the Web form, although in the Access controller has IP and secret key verification, but not sure if there are any security risks.