1.使用命令生成定时任务类:
php artisan make:command RegCustomer
这样会在app/Console/Commands 下生成一个php 文件
在handle中写上你的业务代码,Kernel.php 里面调用
<?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\Stat_Test::class
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('Stat:test')->everyMinute();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}
使用命令生成队列类
php artisan make:job RegCustomer
在handle中写上你的业务代码
外部调用
public function queque(){
\App\Jobs\RegCustomer::dispatch();
echo '王召波队列演示';die;
}
* * * * * php /www/blog-pay/artisan schedule:run
* * * * * php /home/pikiadmin/ec-commerce/blog-pay/artisan schedule:run