-1- What's in your logs?
-2- Don't know what your code do, but why use call job in the loop, you can directly run your sql(s) or see dispatchSync
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
in the console/kernerl.php scheduler runs a job and this jobs run multiple jobs in a loop
$schedule->job(new \App\Jobs\RunProductList)->everySixHours();
RunProductList.php
try {
set_time_limit(3000);
$timeStart = microtime(true);
$products= \App\Product::all();
Log::channel('psrs')->notice('started sending jobs at ' . date("Y-m-d h:i:sa"));
foreach ($products as $product) {
$limit = 20;
$offset = 0;
$suppliers = $product->suppliers()->take($limit)->skip($offset);
while($suppliers->count() > 0 ){
$supplierCode = implode('-',$suppliers->pluck('ps_code')->toArray()) . '-';
$type_codes = ['a-1','a-2'];
foreach ($type_codes as $type_code) {
$today = \App\CalendarDate::where('full_date',today()->format('Y-m-d'))->first();
// from today till the next 7 days get cache
for ($i=$today->id; $i <$today->id + 7 ; $i++) {
\App\Jobs\GetProduct::dispatch($supplierCode,$product,$i,$type_code);
}
}
$offset = $offset + $limit;
$properties = $product->suppliers()->take($limit)->skip($offset);
}
}
$timeEnd = microtime(true);
$executionTime = ($timeEnd - $timeStart);
Log::channel('psrs')->notice('sent the jobs for all the products in '.$executionTime . ' seconds');
} catch (\Throwable $th) {
Log::channel('psrs')->error('could not execute the jobs becuase of the following error');
Log::channel('psrs')->error($th);
}
GetProduct Job has a curl request and updates the results in the database.
Now the issue is that there should be around 4000 requests but only 200 requests (only the first product) is sent and then none of the rest is sent it's like foreach loop only goes through the loop once OR laravel stops the whole process.
each process takes 100 seconds. and it's laravel 7
Please or to participate in this conversation.