Last active
October 16, 2020 18:22
-
-
Save timothycarambat/340c2a14d3a0745cac33378d457ed104 to your computer and use it in GitHub Desktop.
Laravel 8 - AWS Elastic Beanstalk Linux Distro - Use Laravel Scheduler - Confirmed Working Oct 16 2020.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
"/etc/cron.d/schedule_run": | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
* * * * * root export $(cat /opt/elasticbeanstalk/deployment/env | xargs) && /usr/bin/php /var/www/html/artisan schedule:run &> /tmp/schedule_run.log | |
commands: | |
remove_old_cron: | |
command: "rm -f /etc/cron.d/*.bak" | |
#Be sure in your file there is one empty line after the last line of the file. Delete this line though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// File located in App\Console\Kernel.php | |
namespace App\Console; | |
use Log; | |
use App\Helpers\BackgroundWorker; | |
use Illuminate\Console\Scheduling\Schedule; | |
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | |
class Kernel extends ConsoleKernel | |
{ | |
protected $commands = [ | |
// | |
]; | |
protected function scheduleTimezone() { | |
return 'America/Los_Angeles'; | |
} | |
protected function schedule(Schedule $schedule) { | |
$schedule->call(function(){ | |
BackgroundWorker::do_action(); | |
}) | |
->name('bgworker:do_action_one') | |
->weeklyOn(5, '17:00') // Fridays at 5PM | |
$schedule->call(function(){ | |
BackgroundWorker::do_action_two(); | |
}) | |
->name('bgworker:do_action_two') | |
->hourly() | |
->between('9:00', '18:00'); // run hourly between 9AM-6PM | |
} | |
protected function commands() | |
{ | |
$this->load(__DIR__.'/Commands'); | |
require base_path('routes/console.php'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is so much information online about how to schedule:run on laravel but a lot of it is incorrect. This gist is 100% confirmed to be working for Laravel 8 on AWS Elasticbeanstalk Linux AMI.
This will execute the schedule run command every minute and output that to a
/tmp/
file