Laravel task scheduling
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 |
|
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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.

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

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.

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.

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

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.
