3
votes

Laravel error

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

App\Console\Kernel:

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();
    }
}

Logs:

[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}

5
The problem in the version of phpИлья Зеленько
You can mark this as answered if you found the solutionhaakym
This solution. But I do not know how to make a response.Илья Зеленько
What's the solution?Tropicalista
it was necessary to put a higher version of phpИлья Зеленько

5 Answers

4
votes

I also had same problem. I was trying to run cron on cPanel.

What I did is,
* * * * * php-cli -q /path/to/artisan schedule:run >> /dev/null 2>&1

instead of,
* * * * * php /path/to/artisan schedule:run 1>> /dev/null 2>&1

Don't know how but it works for me. Problem might be related to php command prompt.

1
votes

I got the same error configuring Laravel cron jobs on shared cpanel hosting and the other answers didn't work for me, so here is my solution in case it can help someone:

Instead of this:

cd /home/user/path/to/project && /usr/bin/php-cli -q artisan schedule:run

I ended up using this:

/usr/local/bin/ea-php72 /home2/path/to/project/artisan schedule:run

It's basically the same thing as using php-cli as noted in other answers, but on my hosting using /usr/bin/php-cli resulted in another error since it wasn't found. I stumbled on this symlink while looking through the cpanel documentation here: https://documentation.cpanel.net/display/EA4/PHP+Home#PHPHome-ModifyPHP

0
votes

It was necessary to put a higher version of php

0
votes

I have faced this issue, when I was trying to migrate the database using my cpanel terminal. After that I use putty and connect the same server, then use php artisan migrate command, It was solved, Hope it will help.

-1
votes

Error : ArgvInput.php line 280

register_argc_argv is set to off in php.ini

we need to make register_argc_argv should be set to true.

If you are still having the issue, try to use php-cli -q instead of php in the command. Example :
* * * * * php /home/path/to/artisan schedule:run 1>> /dev/null 2>&1
to
* * * * * php-cli -q /home/path/to/artisan schedule:run >> /dev/null 2>&1