Issue
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
You must define project artisan file in cpanel cron command
/usr/local/bin/php /path/to/project/artisan schedule:run >> /dev/null 2>&1
Answered By - Daniel Mesa Answer Checked By - Mildred Charles (WPSolving Admin)