简体   繁体   English

流明调度程序无法使用cron作业

[英]Lumen Scheduler not working using cron jobs

i'm trying to run lumen scheduler and i have used crontab for this purpose and setup a command like this 我正在尝试运行流明调度程序,并且我已经为此使用crontab并设置了这样的命令

* * * * * 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: [2018-11-13 16:31:03]登台。错误:ErrorException:未定义的索引:/home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php:53中的argv堆栈跟踪:

0 /home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php(53): 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) Laravel \\ Lumen \\ Application-> Laravel \\ Lumen \\ Concerns {closure}(8,'Undefined index ...','/ home / humzayun / ...',53,数组)

1 /home/humzayun/fbapp/artisan(34): Symfony\\Component\\Console\\Input\\ArgvInput->__construct() 1 / home / humzayun / fbapp / artisan(34):Symfony \\ Component \\ Console \\ Input \\ ArgvInput-> __ construct()

2 {main} {"exception":"[object] (ErrorException(code: 0): Undefined index: argv at 2 {main} {“ exception”:“ [object](ErrorException(code:0):未定义索引:argv at

/home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php:53) [stacktrace] /home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php:53)[stacktrace]

0 /home/humzayun/fbapp/vendor/symfony/console/Input/ArgvInput.php(53): 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) Laravel \\ Lumen \\ Application-> Laravel \\ Lumen \\ Concerns \\ {closure}(8,'Undefined index ...','/ home / humzayun / ...',53,数组)

1 /home/humzayun/fbapp/artisan(34): Symfony\\Component\\Console\\Input\\ArgvInput->__construct() 1 / home / humzayun / fbapp / artisan(34):Symfony \\ Component \\ Console \\ Input \\ ArgvInput-> __ construct()

2 {main} "} 2 {main}“}

So after trying this all finally now my crontab is doing nothing. 因此,在终于尝试了所有这些之后,现在我的crontab什么也没做。

my code in Kernel.php is 我在Kernel.php中的代码是

<?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 但是当我使用ssh运行此命令时,它会输出http://prntscr.com/lhxxjq

and my lumen log file shows 我的流明日志文件显示

http://prntscr.com/lhxy4g http://prntscr.com/lhxy4g

But by this cron command nothing is working out like i'm doing in ssh. 但是通过此cron命令,没有任何工作像我在ssh中所做的那样。 Any help will be regraded i shall be very thankful to you for help 任何帮助都会被归还,我将非常感谢您的帮助

You'll receive these argv errors when you're not executing the cli version of php. 不执行cli版本的php时,会收到这些argv错误。 You should see (cli) when executing php -v : 执行php -v时,您应该看到(cli)

# 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. 如果看到cgi或fcgi,则说明您使用了错误的二进制文件。


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. 在cron中运行命令时,最好不要始终将输出重定向到/ dev / null,而是收集stderr和stdout来检查错误。 As indicated in the comments, ea-php71 was not in the $PATH . 如注释中所示, ea-php71不在$PATH Using the full path to ea-php71 solved the OP's problem. 使用ea-php71的完整路径解决了OP的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM