3

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}

Cœur
  • 37,241
  • 25
  • 195
  • 267

5 Answers5

4

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.

mgraph
  • 15,238
  • 4
  • 41
  • 75
AmarjaPatil4
  • 1,640
  • 3
  • 28
  • 41
1

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

dmisljen
  • 103
  • 1
  • 4
  • My server is using PHP 7.3 and it was causing this error. Using PHP 7.2 as you pointed fixed the issue. Thanks – Gjaa Sep 12 '19 at 23:27
0

It was necessary to put a higher version of php

0

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

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

Mahak Choudhary
  • 1,286
  • 1
  • 16
  • 13