Search code examples
phplaravelcentos7cyber-panel

Laravel cronjob in server won't run


I have my laravel app installed on subdomain of my website and I've set cronjob but it does not fire.

I've tested my command by terminal and its firing just fine so the issue is all about cronjob and not my command/console I guess.

Code

Does not work

1- /home/example.com/public_html/process.example.com && php artisan schedule:run >> /dev/null 2>&1

2- php /home/example.com/public_html/process.example.com && php artisan schedule:run >> /dev/null 2>&1

kernel.php

protected $commands = [
    Commands\RenewInvoices::class,
];

protected function schedule(Schedule $schedule)
{
  $schedule->command('renew:invoices')
  ->everyMinute();
}

Any idea?


Solution

  • Solved

    Apparently I had to get my php from other place /usr/local/lsws/lsphp74/bin/php rather than /usr/bin/php

    /usr/local/lsws/lsphp74/bin/php /home/example.com/public_html/process.example.com && /usr/local/lsws/lsphp74/bin/php /home/example.com/public_html/process.example.com/artisan schedule:run >> /dev/null 2>&1
    

    To simplify command above and make it easy to read here is it's structure:

    PHP LARAVEL_APP && PHP ARTISAN COMMAND >> /dev/null 2>&1