php-laravel-docker
php-laravel-docker copied to clipboard
Example of triggering jobs on cron schedule?
Hi there, we have a schedule set to run a job on a regular basis but it doesn't seem this job is running. We've added this to the schedule function within app/Console/Kernel.php as outlined in the Laravel task scheduling docs.
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function() {
(new JobListingsSeeder)->run();
})->weekly()->sundays()->at('18:00');
Artisan::call('cache:clear');
$schedule->command('populateCompanyRaiseRounds')->twiceDaily(1, 13);
}
However it doesn't appear that these commands are running. I see that there are Render docs on cron jobs. I was wondering, how can we run Artisan commands on a schedule while hosted on Render?
I think in order to accomplish this we'll need Supervisor to continually boot up the queue:work
and schedule:run
commands. Doing that requires edits to the Dockerfile..
Docs: https://laravel.com/docs/9.x/queues#supervisor-configuration Example with Apache: https://www.chrisgeiger.dev/posts/Running-Laravel-in-Docker-with-supervisord/ Example with Nginx: https://learn2torials.com/a/laravel8-production-docker-image