Laravel “No scheduled commands are ready to run.”

后端 未结 13 1236
囚心锁ツ
囚心锁ツ 2020-12-09 08:39

I\'ve set up the following Laravel commands:

protected function schedule(Schedule $schedule) {
        $schedule->command(\'command:daily-reset\')->dai         


        
13条回答
  •  情深已故
    2020-12-09 08:52

    I think that my blog will help you answer your question. Please see the below or link: Laravel Crontab In many projects, you need use crontab (cron jobs) to execute some tasks as sending email or delete waste record in DB. With Laravel Project, you can do this easier.

    Create a command in Laravel 4:

    Next step, you need to register the command with Laravel CLI. So easy, you open app/start/artisan.php file, and add one line as below:

    Artisan::add(new FirstCommand);
    

    You are done creating Laravel Command. To test, you could use command below:

    $ php artisan user:active
    

    User Active The output above mean you successfully register a command.

    Finally, put your command into the crontab:

    crontab -e
    

    Add line (run command every 2 minutes):

    */2 * * * * php path_to_laravel_project/artisan user:active
    

    That’s all. Thank you for talking time to read this.

提交回复
热议问题