: This article mainly introduces Laravel Task Scheduling. if you are interested in the PHP Tutorial, refer to it. Use a server scheduled task to call the laravel command or method
1. operations to be performed to create a scheduled task under app \ Console \ Commands
Create Command: php artisan make: console test
$ Signature = "testCommand"; the signature here is also used in the task command in kernel. php;
2. call in Kernel. php
Protected $ commands = [
'App \ Console \ Commands \ test', # The artisan set to be called in the application
];
$ Schedule-> command ('testcommand')-> everyMinute (); # The testCommand and the signature in app \ Console \ Commands must be the same
Note: You can also set the time by $ schedule-> command ('testcommand')-> cron ('*****');
3. you also need to configure/etc/CrontabFile
-
-
-
-
-
- Php/path/to/artisan schedule: run 1>/dev/null 2> & 1
The path here is the Project path rather than the file path !!!
In Linux, task scheduling is divided into system and user Task Scheduling:
A.Crontab-E is user-defined and will be written to the/var/spool/cron Directory. it claims that a file consistent with the user name is the edited scheduled script.
[You can go to/var/spool/cron to view the user directory]
Tasks that the user regularly performs, such as user data backup and scheduled email reminders.
B. vim/etc/CrontabSystem-level tasks that the system periodically performs, such as writing cached data to the hard disk and clearing logs.
The above introduces Laravel task scheduling, including some content, and hope to be helpful to friends who are interested in PHP tutorials.