Home Backend Development PHP Tutorial Laravel task scheduling

Laravel task scheduling

Jul 29, 2016 am 09:14 AM
artisan console schedule

Call laravel commands or methods through server scheduled tasks

1. What to do to create a scheduled task under appConsoleCommands

Create command: php artisan make:console test

$signature = "testCommand"; The signature here, in It is also used in the task commands in kernel.php;

2. Call in Kernel.php

protected $commands = [

'AppConsoleCommandstest', #A collection of artisans to be called in the application

];

1

2

<code>$schedule->command('testCommand')->everyMinute(); #这里的testCommand与app\Console\Commands中的签名要相同

</code>

Copy after login

Note: You can also use $schedule->command('testCommand')->cron('* * * * *'); to set the time

3. You also need to configure the /etc/crontab file

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

      Note: Laravel documentation has

          • php / path/to/artisan schedule:run 1>> /dev/null 2>&1

The path here is the path of the project rather than the file path!!!

Tasks under Linux 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 and claims a file consistent with the user name. The content of the file is Edited scheduled script

[You can enter /var/spool/cron to view the user directory]

Work that users need to perform regularly, such as user data backup, scheduled email reminders, etc.

b.vim /etc/crontab belongs to the system level, and the system performs tasks periodically, such as writing cached data to the hard disk, log cleaning, etc.

The above has introduced Laravel task scheduling, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Pre-orders open for new Nintendo Switch Lite refresh Pre-orders open for new Nintendo Switch Lite refresh Jun 29, 2024 am 06:49 AM

Nintendo has opened pre-orders for the latest version of the Switch Lite (curr. $189.99 on Amazon). However, the device is not available to order globally just yet. To recap, the company presented the Switch Lite Hyrule Edition almost two weeks ago d

What does console mean? What does console mean? Sep 05, 2023 pm 02:43 PM

Console means console. It is a device or software that interacts with a computer system. It is usually a device with a keyboard and a screen for inputting and outputting information. The console was originally Used for large computer systems, and later also applied to personal computers and servers, it can help users manage and maintain computer systems, as well as install operating systems and applications, debug programs, etc.

Clear console output using Console.Clear function in C# Clear console output using Console.Clear function in C# Nov 18, 2023 am 11:00 AM

Use the Console.Clear function in C# to clear the console output. In C# console applications, we often need to clear the output information in the console in order to display new content or provide a better user experience. C# provides the Console.Clear function to implement this function, which can clear the output in the console and make the interface blank again. The calling format of the Console.Clear function is as follows: Console.Clear(); This function does not require any input

Nintendo announces new Switch Lite refresh before Switch 2 release Nintendo announces new Switch Lite refresh before Switch 2 release Jun 20, 2024 am 09:41 AM

Nintendo presented plenty of games yesterday during its most recent Nintendo Direct event, an overview of which we have provided separately. Additionally, the company also announced a new version of the Switch Lite (curr. $194.93 on Amazon), possibly

MagicX XU Mini M: Teardown reveals RK3326 CPU instead of advertised RK3562, MagicX severs ties with 3rd-party dev MagicX XU Mini M: Teardown reveals RK3326 CPU instead of advertised RK3562, MagicX severs ties with 3rd-party dev Sep 01, 2024 am 06:30 AM

If you purchased the MagicX XU Mini M recently, this news might come as a surprise. A hardware and software teardown of the newly released handheld console revealed that the advertised RK3562 CPU is, in fact, a lower-specced, older RK3326 processor.

what does console mean what does console mean Aug 09, 2023 pm 04:21 PM

A console is a console, an interactive interface used in computer programs to input and output text or commands. In different operating systems and development environments, the console may have different appearances and functions. Usually a text interface that provides a command line interface or command line prompt, allowing the user to enter commands through the keyboard and display the output of the program.

Nintendo Switch 2 rumored to get ports of Assassin\'s Creed Shadows and previous entries in the series Nintendo Switch 2 rumored to get ports of Assassin\'s Creed Shadows and previous entries in the series Aug 14, 2024 pm 12:36 PM

Last week, Paul Gele, a known gaming insider, shared that the upcoming Nintendo Switch 2 will get major third-party AAA ports at launch. This is something to look forward to because the first-gen gaming handheld didn't get any AAA titles at launch. B

What is the console interface? What is the console interface? Aug 08, 2023 am 11:15 AM

The console interface is a tool for outputting information in the computer command line or browser development tools. It provides a simple way to record and view the output results and debugging information of the application. By using the console interface, developers can identify and solve problems more effectively, optimize application performance, and improve development efficiency. Whether in the command line or browser development tools, the console interface is an indispensable tool.

See all articles