当前位置:网站首页>Laravel task scheduling
Laravel task scheduling
2022-06-25 12:34:00 【qq_ twenty-five million sixty thousand seven hundred and sixty-】
First, start task scheduling
adopt
crontab -e
To add or edit scheduled tasks , adoptcrontab -l
View existing scheduled tasks* * * * * / Yours php The location of /php / Your project location /artisan schedule:run >> /dev/null 2>&1
Define scheduling
php artisan make:command Test \\App\Console\Commands\Test.php
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
use Log;
class Test extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test'; // Command name
/**
* The console command description.
*
* @var string
*/
protected $description = ' Task test '; // Command description
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Log::info('66666');
}
}
app/Console/Kernel.php file
<?php namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel {
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Test::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('test') //Test.php Medium name
->everyMinutes(); // Execute every minute
}
}
Scheduling common options
Method | describe |
---|---|
->cron('* * * * *'); | In the custom Cron Running tasks on a schedule |
->everyMinute(); | Run the task every minute |
->everyFiveMinutes(); | Run the task every five minutes |
->everyTenMinutes(); | Run the task every ten minutes |
->everyFifteenMinutes(); | Run the task every 15 minutes |
->everyThirtyMinutes(); | Run the task every 30 minutes |
->hourly(); | Run the task every hour |
->hourlyAt(17); | Run the task every seventeen minutes of the hour |
->daily(); | Run the mission at 0 a.m. every morning |
->dailyAt('13:00'); | Every day 13:00 Run the task |
->twiceDaily(1, 13); | Every day 1:00 & 13:00 Run the task |
->weekly(); | Run the task once a week |
->monthly(); | Run the task once a month |
->monthlyOn(4, '15:00'); | monthly 4 Number 15:00 Run a task |
->quarterly(); | Run Quarterly |
->yearly(); | Run once a year |
->timezone('PRC'); | Set time zone |
边栏推荐
- The first techo day Tencent technology open day in 2022 will be held online on June 28
- Hook technology
- Kotlin study notes
- Kotlin Foundation
- Dynamic proxy
- Is it safe to open an account and buy stocks on the Internet?
- ARM V7 ldr str 内存访问
- The R language uses the follow up The plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses stress The type parameter specifies the line type of
- Happy shopkeeper source code -- Introduction to happy shopkeeper system development mode
- R language dplyr package filter function filters the data rows in the specified list whose contents in the dataframe data are not (not equal to one of the specified vectors)
猜你喜欢
15、wpf之button样式小记
Navicat premium view password scheme
How do super rookies get started with data analysis?
Explanation of ideas and sharing of pre-processing procedures for 2021 US game D (with pre-processing data code)
Installation and removal of MySQL under Windows
The first techo day Tencent technology open day in 2022 will be held online on June 28
【数据中台】数据中台的OneID是个什么鬼,主数据它不香吗?
Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
[oceanbase] Introduction to oceanbase and its comparison with MySQL
Today, I will explain to you what is DFI and its development prospects
随机推荐
Découvrir gaussdb (pour redis): une comparaison complète avec Codis
JQ dynamic setting radio does not take effect when selected
Understanding and construction of devsecops and Devops
PHP files running online
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the summary function to obtain the summary statistical information
Happy shopkeeper source code -- Introduction to happy shopkeeper system development mode
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用summary函数获取模型汇总统计信息
Set the transparency of the picture to gradient from left to right
Lighten the source code -- lighten the app system development function introduction to the beautiful world lighten the app system development source code in China
Does sklearex make your sklearn machine learning model training fly fast?
Fun pocket mall -- sharing the development source code of fun pocket app system
Penetration tool environment -- use of cknife Chinese kitchen knife
Mind mapping video
The server reported an error 503 service unavailable:the system returned: (71) protocol error
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the lrtest function of epidisplay package to perform multiple model
ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities
Zhangxiaobai's way of penetration (III) -- detailed explanation of SQL injection vulnerability principle (SQL Server)
15、wpf之button样式小记
ARM V7 协处理器
confluence7.4. X upgrade record