我已将我的命令注册为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
中并调用它,它截断表意味着命令正在执行其工作。
答案 0 :(得分:0)
在Kernel.php中,您的命令应包含在:
中/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
MyCommand::class
];
您也可以删除Inspire:)