当前位置:网站首页>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 -eTo add or edit scheduled tasks , adoptcrontab -lView 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 |
边栏推荐
- Mysql database logs binlog save aging (expire\u logs\u days)
- Rank sum ratio comprehensive evaluation method for common models in mathematical modeling
- 20、wpf之MVVM命令绑定
- Tp6 exception handling try catch writing method
- Possible causes of wechat applet decryption failure
- 15、wpf之button样式小记
- Kotlin study notes
- ECSHOP product attribute color specification size stock item No. automatic combination
- Ubuntu uninstalling PHP
- thinkphp3.2.5 GIF. class. php for php7.4
猜你喜欢

20. MVVM command binding of WPF

Dark horse shopping mall ---2 Distributed file storage fastdfs

Zhangxiaobai's way of penetration (VIII) - detailed operation steps of SQL injection - Boolean blind injection of blind injection

Time series analysis - how to use unit root test (ADF) correctly?

Why do we do autocorrelation analysis? Explain application scenarios and specific operations
![[oceanbase] Introduction to oceanbase and its comparison with MySQL](/img/1c/bd2bcddb7af4647407d2bc351f5f5d.png)
[oceanbase] Introduction to oceanbase and its comparison with MySQL

Zhangxiaobai's road of penetration (VI) -- the idea and process of SQL injection and the concat series functions and information of SQL_ Schema database explanation

Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection

K8s, docker compose install MySQL 8.0.18

How do super rookies get started with data analysis?
随机推荐
Array reorder based on a field
Windows下MySQL的安装和删除
A commonly used statistical modeling method -- difference analysis
[on]learning dynamic and hierarchical traffic spatiotemporal features with transformer
PHP numeric array sorting and associative array sorting
Concise H5 error page
ECSHOP video list_ ECSHOP uploading video, video classification, video list playing video function
A set of automated paperless office system (oa+ approval process) source code: with data dictionary
一款好用的印章设计工具 --(可转为ofd文件)
Use PHP script to view the opened extensions
Hook technology
Time series analysis - how to use unit root test (ADF) correctly?
Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
ARM V7 ldr str 内存访问
How can we differ LEFT OUTER JOIN vs Left Join [duplicate]
20、wpf之MVVM命令绑定
R language uses GLM function to build Poisson logarithmic linear regression model, processes three-dimensional contingency table data to build saturation model, and poisgof function of epidisplay pack
confluence7.4. X upgrade record
Micro engine generates QR code
Is it safe to open an account and buy stocks on the Internet?