Tuesday, March 7, 2017

Laravel 5.2 scheduled commands not running, only running with sudo php artisan

I've configured some scheduled tasks on my project but some of them are not running unless I run them on command line and using sudo, like

sudo php artisan command

I also tried

php artisan schedule:run

But they don't run also. Not even with sudo.

So in my kernel.php I got this:

protected $commands = [
    Commands\GISUpdateInventory::class,
    Commands\GISUpdatePricelists::class,
    Commands\GISAllocOrders::class,
    Commands\ERPChildFetcher::class,
    Commands\UpdateDashboard::class,
    Commands\Inspire::class,
    Commands\CronLogger::class,
];

The schedule method is this:

protected function schedule(Schedule $schedule)
{
    $schedule->command('CronLog')->everyMinute();
    $schedule->command('GISAllocOrders')->everyTenMinutes();
    $schedule->command('ERPChildFetcher')->everyTenMinutes();
    $schedule->command('UpdateInventory')->hourly();
    $schedule->command('UpdatePricelists')->hourly();
}

  • The first command (CronLog) is only a test command, it should write a log message. This doesn't run.
  • The second and third commands (GISAllocOrders, ERPChildFetcher) don't run. Those include soap calls and write to the log file. These only run using php artisan in command line / console and using sudo.
  • Fourht and fifth commands DO run. Those make database queries, write to the log file, write xml/json files.

There's nothing about second and third commands in the log file, no error, no soap faults, no log information. Just nothing.

This is my crontab (which is working because the last two commands does run):

* * * * * php /var/www/laravel/artisan schedule:run >> /dev/null 2>&1

It's very frustrating because without log error messages I can't debug. I don't know what's going on. Please any advice would be very appreciate it.

Thanks in advance.



via Chuy

Advertisement