6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravelで処理を定期実行する方法

6
Posted at

Laravelで処理を定期実行する方法

備忘録です。

app/Console/Commands/Kanel.phpに定期的に実行したい処理を記述する

Kanel.php
protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        \Log::info('hello');
    })->everyMinute();
}

クーロンテーブルに追加する

crontab -e

/path/toをプロジェクトのパスに置き換える(pwdしてコピーするのが楽)

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1

これで定期的にLogファイルにhelloが出力されます。

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?