Reputation: 3
i'm trying to run lumen scheduler and i have used crontab for this purpose and setup a command like this
* * * * * cd /home/humzayun/fbapp && ea-php71 artisan schedule:run >> /dev/null 2>&1
before this i tried using
* * * * * cd /home/humzayun/fbapp && php artisan schedule:run >> /dev/null 2>&1
but in log file it was throwing errors
[2018-11-13 16:31:03] staging.ERROR: ErrorException: Undefined index: argv in /home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php:53 Stack trace:
0 /home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php(53):
Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}(8, 'Undefined index...', '/home/humzayun/...', 53, Array)
1 /home/humzayun/fbapp/artisan(34): Symfony\Component\Console\Input\ArgvInput->__construct()
2 {main} {"exception":"[object] (ErrorException(code: 0): Undefined index: argv at
/home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php:53) [stacktrace]
0 /home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php(53):
Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(8, 'Undefined index...', '/home/humzayun/...', 53, Array)
1 /home/humzayun/fbapp/artisan(34): Symfony\Component\Console\Input\ArgvInput->__construct()
2 {main} "}
So after trying this all finally now my crontab is doing nothing.
my code in Kernel.php is
<?php
namespace App\Console;
use Facebook\Facebook;
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
use PharIo\Manifest\Email;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function (Facebook $facebook){
\Log::info($facebook->getDefaultAccessToken());
echo " yayy here ";
})->everyMinute();
}
}
Now the issue is that log is reporting nothing.
but when i run this command using ssh it output http://prntscr.com/lhxxjq
and my lumen log file shows
But by this cron command nothing is working out like i'm doing in ssh. Any help will be regraded i shall be very thankful to you for help
Upvotes: 0
Views: 2875
Reputation: 35337
You'll receive these argv
errors when you're not executing the cli version of php. You should see (cli)
when executing php -v
:
# php -v
PHP 7.1.20 (cli) (built: Jul 25 2018 10:06:40) ( NTS )
If you see cgi or fcgi, then you're using the wrong binary.
When running commands in cron, it's best not to always redirect output to /dev/null and instead collect the stderr and stdout to review for errors. As indicated in the comments, ea-php71
was not in the $PATH
. Using the full path to ea-php71
solved the OP's problem.
Upvotes: 0