[英]Cron jobs on shared hosting using laravel scheduler not working
[英]Lumen Scheduler not working using cron jobs
我正在嘗試運行流明調度程序,並且我已經為此使用crontab並設置了這樣的命令
* * * * * cd /home/humzayun/fbapp && ea-php71 artisan schedule:run >> /dev/null 2>&1
在此之前,我嘗試使用
* * * * * cd /home/humzayun/fbapp && php artisan schedule:run >> /dev/null 2>&1
但在日志文件中它拋出錯誤
[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):
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()
2 {main} {“ exception”:“ [object](ErrorException(code:0):未定義索引: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,數組)
1 / home / humzayun / fbapp / artisan(34):Symfony \\ Component \\ Console \\ Input \\ ArgvInput-> __ construct()
2 {main}“}
因此,在終於嘗試了所有這些之后,現在我的crontab什么也沒做。
我在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();
}
}
現在的問題是日志什么也沒報告。
但是當我使用ssh運行此命令時,它會輸出http://prntscr.com/lhxxjq
我的流明日志文件顯示
但是通過此cron命令,沒有任何工作像我在ssh中所做的那樣。 任何幫助都會被歸還,我將非常感謝您的幫助
不執行cli版本的php時,會收到這些argv
錯誤。 執行php -v
時,您應該看到(cli)
:
# php -v
PHP 7.1.20 (cli) (built: Jul 25 2018 10:06:40) ( NTS )
如果看到cgi或fcgi,則說明您使用了錯誤的二進制文件。
在cron中運行命令時,最好不要始終將輸出重定向到/ dev / null,而是收集stderr和stdout來檢查錯誤。 如注釋中所示, ea-php71
不在$PATH
。 使用ea-php71
的完整路徑解決了OP的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.