gpt4 book ai didi

php - laravel cron 使用错误

转载 作者:行者123 更新时间:2023-12-02 07:56:05 26 4
gpt4 key购买 nike

Laravel 错误

cron uses /usr/bin/php /home/sitevk/artisan schedule:run 1>> /dev/null: 2>&1

应用\控制台\内核:

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\User;
use Log;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
Log::info('1');
$schedule->call(function () {
$user = User::find(1);
$user->first_name = 'cron...';
$user->save();
})->everyMinute();
}
}

日志:

[2015-08-31 19:14:02] local.ERROR: exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /home/sitevk/vendor/symfony/console/Input/ArgvInput.php:287 Stack trace: #0 /home/sitevk/vendor/symfony/console/Input/ArgvInput.php(287): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/sitevk/ve...', 287, Array)
#1 /home/sitevk/vendor/symfony/console/Application.php(827): Symfony\Component\Console\Input\ArgvInput->hasParameterOption(Array)
#2 /home/sitevk/vendor/symfony/console/Application.php(123): Symfony\Component\Console\Application->configureIO(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/sitevk/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(100): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/sitevk/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}

最佳答案

我也遇到了同样的问题。我试图在 cPanel 上运行 cron。

我所做的是,
* * * * * php-cli -q/path/to/artisan Schedule:run >>/dev/null 2>&1

而不是,
* * * * * php/path/to/artisan Schedule:run 1>>/dev/null 2>&1

不知道如何,但它对我有用。问题可能与 php 命令提示符有关。

关于php - laravel cron 使用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32318854/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com