Answer the question
In order to leave comments, you need to log in
Why is Cron not running a Laravel command?
Tell me, I can’t understand why the Laravel scheduler doesn’t want to run through cron from under user, but it runs fine from under root.
Ubuntu system, Laravel 5.4, PHP 7.
<?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\CommandMy'
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('command:my')->withoutOverlapping()->everyTenMinutes();
}
}
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Http\Controllers\MyController;
class CommandMy extends Command
{
protected $signature = 'command:my';
protected $description = 'My command';
protected $contr;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(MyController $my)
{
parent::__construct();
$this->func=$my;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info($this->func);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question