[英]running cron job in laravel 5
I have registered my command as php artisan run:process
and it looks like 我已经将命令注册为
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();
}
}
this is my kernel.php
这是我的
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();
}
}
Now I want to run php artisan run:process
every minute and truncate transfers
table, but the cron
is not working now. 现在我想每分钟运行一次
php artisan run:process
并截断transfers
表,但是cron
现在无法正常工作。 Just to make sure, if the command
itself is working or not , I put my command
inside my routes
and call it, its truncating the table meaning command is doing its work. 为了确保
command
本身是否正常工作,我将command
放入routes
并对其进行了调用,该命令将截断表格意味着命令正在执行其工作。
In Kernel.php your command should be included in: 在Kernel.php中,您的命令应包含在:
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
MyCommand::class
];
You can probably remove Inspire too :) 您可能也可以删除Inspire :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.