-1

Same problem schedule cron job,

my kernal.php

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Log;

use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{

    protected $commands = [
      //  \App\Console\Commands\SecondTable::class,
    ];


    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
                  //->hourly();
        $schedule->call('App\Http\Controllers\Sale\SaleController@sync')->everyMinute();
    }

    protected function commands()
    {
        require base_path('routes/console.php');
    }
}

manually running a command-> php artisan schedule:run is working good!

but, cronjob run server is not working correctly, my cron job code,

* * * * * php /laravel project folder/artisan schedule:run >> /dev/null 2>&1

is not working.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Gowtham B
  • 3
  • 1
  • 8

1 Answers1

0

Check your cronjob code, it could be something like this:

* * * * * cd path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

It means: every seconds (* * * * *), go to my project folder (cd path-to-your-project), then execute the command (php artisan schedule:run).

The meaning of the last part of the cronjob is explained here: What is /dev/null 2>&1?

Stefano
  • 179
  • 2
  • 13
  • I have run a command in server, like this https://i.ibb.co/6tMzgZR/error.png but, now working. (Laravel 5.4) – Gowtham B Jun 20 '19 at 05:05
  • sorry my Laravel version 5.6.4 – Gowtham B Jun 20 '19 at 07:30
  • You have to type "php" before "artisan" in your cron job (it is missing in the image you linked). You can see it in my response. – Stefano Jun 20 '19 at 09:49
  • To run your cronjob in the shell while testing you have to remove * * * * * because it is reserved for the crontab – Stefano Jun 20 '19 at 09:55
  • i have set path crontab in server. Then run a /usr/bin/php7.0 /mnt/hosting/dev/projects folder/artisan schedule:run >> /dev/null 2>&1 manually run working good. but, create a shell file in server. run a 5 minutes only cron job excuted. not working i dont know problem. – Gowtham B Jun 20 '19 at 10:10
  • Can you copy and paste here your exact crontab (check it typing crontab -e in your shell)? – Stefano Jun 20 '19 at 10:24
  • Thanks given suggestions, /usr/bin/php7.0 /mnt/hosting/dev/projects folder path/artisan schedule:run >> /dev/null 2>&1 this code working good. any reference, https://stackoverflow.com/questions/43699948/laravel-5-4-task-scheduler?rq=1 – Gowtham B Jun 20 '19 at 11:47