Home > Back-end >  how to auto run schedualing in laravel
how to auto run schedualing in laravel

Time:09-19

I'm new in laravel and i need to swlwtw otps expired in my otps database,i create a expiration file and define all things,and the command run perfect when i use php artisan schedule:run

this is the output:

2022-09-17 16:37:15 Running ['artisan' Otp:expire] in background .......................................... 7ms DONE
  ⇂ ('/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 i add an otp the otp didn't be deleted after the time expected,it delete only when i use schedule run. any help please?

CodePudding user response:

The official laravel documentation suggests running the php artisan schedule:run command every minute by using a cron (Cronjob etc.). You can do it by using the following cron entry:

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

CodePudding user response:

The best way is to use Supervisor, which runs your command constantly, and when the process finishes the new one will start immediately. If you use Cronjob, you should know that It runs every process for a minute minimum! Please check the Laravel documentation

  • Related