'Laravel schedule job on cpanel shared hosting not working

I have implement laravel queues to my application but facing issues with scheduling cron jobs with cPanel in shared hosting .

The directory structure on shared hosting is:

  • Project
  • public_html

project/app/console/kernel.php There I have updated schedule command.

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
     $schedule->command('queue:work --stop-when-empty')
              ->everyMinute();
}

command in cpanel cron

/usr/local/bin/php /home/shope/public_html/ php artisan schedule:run >> /dev/null 2>&1

Note: This is working fine on my local machine when schedule command run in terminal.

php artisan schedule:run

output:

Running scheduled command: '/usr/bin/php7.4' 'artisan' queue:work --stop-when-empty > '/dev/null' 2>&1


Solution 1:[1]

You must define project artisan file in cpanel cron command

/usr/local/bin/php /path/to/project/artisan schedule:run >> /dev/null 2>&1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1