简体   繁体   中英

Laravel 9 error: Command "schedule:run " is not defined

I have dockerized my project and I am using cron.d to run Laravel schedules.

This is the content of my cron file:

* * * * * /usr/local/bin/php /var/www/artisan schedule:run

I even checked that there's no extra space at the end of the file. Yet, whenever it is run, Laravel throws an error that says "schedule:run " is not a command. This is the full error:

[2022-08-23 08:13:06] local.ERROR: Command "schedule:run
" is not defined.
Did you mean one of these?
    schedule:clear-cache
    schedule:list
    schedule:run
    schedule:test
    schedule:work {"exception":"[object] (Symfony\\Component\\Console\\Exception\\CommandNotFoundException(code: 0): Command \"schedule:run
\" is not defined.

Did you mean one of these?
    schedule:clear-cache
    schedule:list
    schedule:run
    schedule:test
    schedule:work at /var/www/vendor/symfony/console/Application.php:692)
[stacktrace]
#0 /var/www/vendor/symfony/console/Application.php(259): Symfony\\Component\\Console\\Application->find()
#1 /var/www/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun()
#2 /var/www/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\\Component\\Console\\Application->run()
#3 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run()
#4 /var/www/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#5 {main}
"} 

This has been driving me crazy for hours. I have previously used the same configuration for Docker in one of my earlier projects using Laravel 7. So, it could be a Laravel 9 issue. Or is there something really obvious that I'm missing here?

I suggest reading the documentation

so try

    * * * * * cd /var/www/ && php artisan schedule:run >> /dev/null 2>&1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM