H
H
Henry2017-11-27 14:35:49
Task Schedulers
Henry, 2017-11-27 14:35:49

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.

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\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();
    }

}
CommandMy.php
<?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);
    }
}
cronetab -l -u user:
* * * * * php /var/www/artisan schedule:run 1>> /dev/null 2>&1
or
cronetab -l -u root:
* * * * * php /var/www /artisan schedule:run 1>> /dev/null 2>&1
At the same time:
- the artisan command:my command works fine
- and artisan schedule:run writes: No scheduled commands are ready to run
How can this be? Any thoughts?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-11-27
@Henryh

via cron from under user, but it runs fine from under root.

It doesn't look like a permissions issue. Maybe the user does not have the rights not to write to the logs, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question