I'm working with Schedular
in Laravel 5.8
. after setting up the Commands
and Command Kernal
I'm getting the error as,
Invalid argument supplied for foreach() at /home/SERVER_USER_NAME/public_html/vendor/symfony/console/Input/ArgvInput.php:261)
Here is the Kernal
methods,
protected $commands = [
Commands\OfferMonitor::class,
Commands\RankingCommand::class,
Commands\CreditCycle::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('KG:OfferMonitor')->dailyAt('01:00');
$schedule->command('KG:UpdateRanks')->everyTenMinutes();
$schedule->command('KG:CreditCycle')->dailyAt('00:00');
}
Here is my Laravel Cron Job
running on production server,
I think the cron job itself throws an error, I'm using php
binary instead of php-cli
. Does it caused error? if yes, what's the workaround to this issue?
Here is the complete error log and stacktrace from Laravel,
Invalid argument supplied for foreach() {"exception":"[object] (ErrorException(code: 0): Invalid argument supplied for foreach() at /home/SERVER_USER_NAME/public_html/vendor/symfony/console/Input/ArgvInput.php:261)
[stacktrace]
#0 /home/SERVER_USER_NAME/public_html/vendor/symfony/console/Input/ArgvInput.php(261): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/SERVER_USER_NAME...', 261, Array)
#1 /home/SERVER_USER_NAME/public_html/vendor/symfony/console/Application.php(970): Symfony\\Component\\Console\\Input\\ArgvInput->getFirstArgument()
#2 /home/SERVER_USER_NAME/public_html/vendor/laravel/framework/src/Illuminate/Console/Application.php(81): Symfony\\Component\\Console\\Application->getCommandName(Object(Symfony\\Component\\Console\\Input\\ArgvInput))
#3 /home/SERVER_USER_NAME/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(133): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#4 /home/SERVER_USER_NAME/public_html/artisan(36): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#5 {main}
"}
Note: The
Commands
scheduled inKernal.php
is running properly when I use them withartisan
from terminal, so there is no issue about command.
Try setting the cron command as this
/usr/local/bin/php register_argc_argv=1 artisan schedule:run >> /dev/null 2>&1