We are currently developing a project using the laravel framework. The project requires some data. The required data is obtained by performing associated queries, calculations, and processing on dozens of tables in the database. Due to the large amount of data, the company requires writing A scheduled task starts executing at every night at 0 o'clock and ends after all the data has been processed. I have now written a method in the laravel controller to process the data in the database. Now I only need to execute this method in a regular loop to achieve the function.
But now I don’t know how to execute it regularly? Is it executed in php cli mode? Or use artisan console to execute? Looking for some advice?
crontab Use the Linux wget or curl command to access your controller through HTTP requests.
1. For large amounts of data, it is best not to pull it out of the application layer and write a MySQL stored procedure or function. (The call can be called through mysql event), this processing will save resources very much.
2. Still writing to the stored procedure, you can cooperate with the crond scheduled task in Linux for scheduled processing.
Laravel’s Scheduling I think fits your needs very well. The Chinese documentation is here.
http://d.laravel-china.org/do...
Laravel has a task scheduling function. It is recommended to read more documents~
According to your situation, the simplest one is laravel's task scheduling
contrab
This depends on the needs of your company. If there is operation and maintenance, you can write a method to operate the data yourself, and let the operation and maintenance write a script to request this method regularly. If there is no operation and maintenance and your boss will not let you touch the server, you can choose to write a PHP script to manipulate the data, use sleep and loops to do it, put the file in the connection, and use the header function to access the request link
Let me recommend several libraries for scheduled tasks. Use composer to load
Dispatcher Laravel-based scheduled task management
swoole-crontab swoole-based timer program that supports second-level processing
jobby A PHP scheduled task manager
cronlingo Express crontabs as human friendly phrases
If you have nothing to do, you can go to awesomes- View it in php
If you can’t read English, I have a backup here and you can also view it by clicking here to jump