You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not 100% sure if it's a bug or just something i'm doing wrong.
I have an issue with a cronjob running the Laravel scheduler.
Info:
The Cronjob runs every minute like described in the laravel docs : app/production/current && php artisan tenants:artisan schedule:run >> /tmp/export-job-prod.log 2>&1
This will trigger the run schedule of laravel and it will start executing the jobs:
namespaceApp\Console;
useApp\Jobs\CloseExpiredWorkSessionsJob;
useApp\Jobs\ExportAllCSVDataToGoogleDriveJob;
useApp\Jobs\ExportLmraOverviewCSVDataToGoogleDriveJob;
useIlluminate\Console\Scheduling\Schedule;
useIlluminate\Foundation\Console\KernelasConsoleKernel;
useApp\Models\Tenant\Tenant;
classKernelextendsConsoleKernel
{
/** * The Artisan commands provided by your application. * * @var array */protected$commands = [
//
];
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */protectedfunctionschedule(Schedule$schedule)
{
if(Tenant::current()){
//SCHEDULES CAN ONLY BE ADJUST ON STAGING$schedule->job(ExportAllCSVDataToGoogleDriveJob::class)->dailyAt('2:00');
$schedule->job(ExportLmraOverviewCSVDataToGoogleDriveJob::class)->hourly();
$schedule->job(CloseExpiredWorkSessionsJob::class)->hourly();
}
}
/** * Register the commands for the application. * * @return void */protectedfunctioncommands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
Let's say it's now 2:00 and the cronjob is triggered:
When it starts it loops over all 7 tenants one by one and executes all 3 jobs per tenant.
The largest job is the ExportAllCSVDataToGoogleDriveJob::class and depending on the client it take up somewhere from 10 upto 40 seconds. The first 3 or 4 tenant jobs all are being executed , the 4th tenant is a rather big one and sometimes it takes upto 40seconds.
So when it hits the 5th to 7th client, nothing gets executed anymore because by that time it is already 2:01 and it just doesn't execute the "hourly" jobs anymore.
When it runs at other times and does not execute the large job per tenant the other two jobs are successfully executed due to the fact that it runs under a minute.
When i change all jobs to run ->everyMinute() and only execute the cron job every hour everything works fine since it always hits the jobs and the "condition" every minute still stands.
So i'm not sure it's a bug or i'm just using the wrong approach here. Is there a way to run the cron task every minute but use the laravel ->hourly() functionality without it stopping on tenants that get executed on hour:01?
Thanks in advance.
Best regards,
Bart M.
The text was updated successfully, but these errors were encountered:
Hi,
I'm not 100% sure if it's a bug or just something i'm doing wrong.
I have an issue with a cronjob running the Laravel scheduler.
Info:
The Cronjob runs every minute like described in the laravel docs :
app/production/current && php artisan tenants:artisan schedule:run >> /tmp/export-job-prod.log 2>&1
This will trigger the run schedule of laravel and it will start executing the jobs:
Let's say it's now 2:00 and the cronjob is triggered:
When it starts it loops over all 7 tenants one by one and executes all 3 jobs per tenant.
The largest job is the
ExportAllCSVDataToGoogleDriveJob::class
and depending on the client it take up somewhere from 10 upto 40 seconds. The first 3 or 4 tenant jobs all are being executed , the 4th tenant is a rather big one and sometimes it takes upto 40seconds.So when it hits the 5th to 7th client, nothing gets executed anymore because by that time it is already 2:01 and it just doesn't execute the "hourly" jobs anymore.
Log below:
When it runs at other times and does not execute the large job per tenant the other two jobs are successfully executed due to the fact that it runs under a minute.
When i change all jobs to run
->everyMinute()
and only execute the cron job every hour everything works fine since it always hits the jobs and the "condition" every minute still stands.So i'm not sure it's a bug or i'm just using the wrong approach here. Is there a way to run the cron task every minute but use the laravel ->hourly() functionality without it stopping on tenants that get executed on hour:01?
Thanks in advance.
Best regards,
Bart M.
The text was updated successfully, but these errors were encountered: