I am new to Laravel and I need to delete expired OTPs in my OTP database, I created an expires file and defined everything, when I use the php artisan schedule:run
command , it works perfectly.
This is the output:
2022-09-17 16:37:15 在后台运行 ['artisan' Otp:expire] .......................................... 7ms 完成 ⇂ ('/usr/bin/php8.1' 'artisan' Otp:expire > '/dev/null' 2>&1 ; '/usr/bin/php8.1' 'artisan' schedule:finish "framework/schedule-7ff27dde37314470633aef84f65f27b83fd05b4e" "$?") > '/dev/null' 2>&1 &
But when I run the server with php artisan serve
and add an OTP, the OTP is not deleted after the expected time, it is deleted only when I use schedule run.
Please help, thank you!
P粉4784456712023-09-08 10:53:42
Official Laravel Documentation It is recommended to use cron (Cronjob, etc.) to run the php artisan schedule:run
command every minute. You can do this via the following cron entry:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1