Skip to content

Instantly share code, notes, and snippets.

@mikehins
Last active May 16, 2017 14:27
Show Gist options
  • Save mikehins/4dc92a904f334bf02f1123157d7484e3 to your computer and use it in GitHub Desktop.
Save mikehins/4dc92a904f334bf02f1123157d7484e3 to your computer and use it in GitHub Desktop.
Laravel Scheduler Command

Je dois migrer / transformer la bd de prod vers celle de staging à chaque soir avec le scheduler.

j'ai un peux plus que 100 000 records à transformer par table, y a une table avec au dessus de 250 000 records en f*** json qui faut que je sépare en plusieurs autres relations

$schedule->command('acme:command1')->timezone('America/Toronto')->dailyAt('20:00')->after(function(){
  $this->call('acme:command2'); 
  $this->call('acme:command3'); 
  $this->call('acme:command4');
  $this->call('acme:command5');
  $this->call('acme:command6');
  $this->call('acme:command7');
  $this->call('acme:command8');
  $this->call('acme:command9');
  $this->call('acme:command10');
  $this->call('acme:command11');
  $this->call('acme:command12');
  ...
  $this->call('acme:command24');

})->sendOutputTo(storage_path('cron.txt'))->emailOutputTo('me@acme.com');

Console Output

Le script fini par crasher... Est-ce que c'est possible que la mémoire se vide après chaque commandes ?

2017-05-16 09:52:42 Command1. Memory usage : 11.19 MB - Peak memory usage : 11 MB
2017-05-16 09:52:42 Command2 done. Memory usage : 11.85 MB - Peak memory usage : 12 MB
2017-05-16 09:52:42 Command3 done. Memory usage : 11.85 MB - Peak memory usage : 12 MB
2017-05-16 09:55:23 Command4 done. Memory usage : 14.31 MB - Peak memory usage : 676 MB
2017-05-16 09:55:29 Command5 done. Memory usage : 15.06 MB - Peak memory usage : 676 MB
2017-05-16 09:55:29 Command6 done. Memory usage : 15.19 MB - Peak memory usage : 676 MB
2017-05-16 09:55:47 Command7 done. Memory usage : 16.88 MB - Peak memory usage : 676 MB
2017-05-16 09:55:47 Command8 done. Memory usage : 16.95 MB - Peak memory usage : 676 MB
2017-05-16 09:55:47 Command9 done. Memory usage : 17 MB - Peak memory usage : 676 MB
2017-05-16 09:57:14 Command10 done. Memory usage : 17.07 MB - Peak memory usage : 676 MB
2017-05-16 10:00:34 Command11 done. Memory usage : 17.16 MB - Peak memory usage : 676 MB
Killed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment