2

Do laravel crons can use the same database connection if executed at the same ti...

 2 years ago
source link: https://dev.to/pcmagas/do-laravel-crons-can-use-the-same-database-connection-if-executed-at-the-same-time-on-laravel-58-3f83
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Do laravel crons can use the same database connection if executed at the same time on laravel 5.8?

Can somebody help me with this?

stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg

Nov 18 '21 Comments: 1 Answers: 0

Ι have setup 2 laravel cronjobs that both run run queries to the database:

$schedule->command(MyCommand::class,['param', '1'])->daily('1:30')
$schedule->command(MyCommand::class,['param', '2'])->daily('1:30');

And the command is the following:

use Illuminate\Console\Command;

class MyCommand extends Command
{
   $signature = "my:command --param {param}"

   public function run()
   {
      $sql = DB::select(^some_heavy_query^);
      // Do other stuff
   }
}

Both…


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK