[英]running cron job in laravel 5
我已经将命令注册为php artisan run:process
,看起来像
class queuedTransaction extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'run:process';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Running the queued transaction.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle(){
DB::table('transfers')->truncate();
}
}
这是我的kernel.php
class Kernel extends ConsoleKernel
{
protected $commands = [
\App\Console\Commands\Inspire::class,
\App\Console\Commands\queuedTransaction::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('run:process')->everyMinute();
}
}
现在我想每分钟运行一次php artisan run:process
并截断transfers
表,但是cron
现在无法正常工作。 为了确保command
本身是否正常工作,我将command
放入routes
并对其进行了调用,该命令将截断表格意味着命令正在执行其工作。
在Kernel.php中,您的命令应包含在:
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
MyCommand::class
];
您可能也可以删除Inspire :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.