Thinkphp 3.2.3 Specific implementation examples of scheduled Tasks tutorial
In many cases, our site will be used to schedule tasks that are scheduled updates to do some processing, similar to the discuz background of the scheduled tasks, such as updating the number of daily posts and so on!
TP is also possible here, first in the application public configuration directory under the new crons.php, write:
<?php return array ( ‘cron_1‘ => array ( ‘Uploads‘ , 1), //行为扩展 ); |
Parameter description:
‘cronname‘ => array ( ‘filename‘ ,intervals,nextruntime), //cronname是任务名 filename是任务文件名 intervals间隔时间 nextruntime下次执行时间 |
Then also create a new tags.php in the application public configuration directory, write:
<?php return array ( ‘app_end‘ => array ( ‘Behavior\CronRunBehavior‘ ), ); |
Then in the application public directory to create a new cron directory, the user to hold some of the specific operation of the task code, as above in the Cron directory in the new uploads.php file for processing cron_1 this scheduled task processing!
Note that this is written in a public profile, and if you want to perform this scheduled task separately for a group, you can write it in a grouped profile!
Thinkphp 3.2.3 Specific implementation examples of scheduled Tasks tutorial