Laravel task scheduling

Source: Internet
Author: User
: 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

          • Root php/home/vagrant/Code/artisan schedule: run

      Note: The laravel document has

          • 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.

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: 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.