LoginSignup
1
0

More than 1 year has passed since last update.

laravel 時間を指定してバッチを実行する 個人メモ

Posted at

目的

  • laravelにて時間を指定してバッチを実行する方法をメモ的にまとめる

方法

  1. 下記ファイルを開く。
    • アプリ名ディレクトリ/app/Console/Kernel.php
  2. Kernelクラスのschedule()メソッドに時間で実行したいバッチの情報を記載する。

    アプリ名ディレクトリ/app/Console/Kernel.php
    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('command:バッチ名')->実行タイミングの指定;
    }
    
  3. 例えば毎日12:00に実行指定ほしいバッチを登録する場合下記のように記載する。

    アプリ名ディレクトリ/app/Console/Kernel.php
    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('command:バッチ名')->dailyAt('12:00');
    }
    

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0