[英]Laravel 5.4 task scheduler
I have setup scheduler according to the Laravel 5.4 documentation. 我有根据Laravel 5.4文档设置的调度程序。 But it doesn't work.
但这是行不通的。
My cron job is: 我的Cron工作是:
* * * * * php public_html/demo/artisan schedule:run 1>> logs/cronlog.txt
app/console/ Kernel.php : app / console / Kernel.php :
class Kernel extends ConsoleKernel
{
protected $commands = [Commands\OverdueTasksNotifier::class,];
protected function schedule(Schedule $schedule)
{
$schedule->command('notify:overduetasks')->everyFiveMinutes();
}
protected function commands()
{
require base_path('routes/console.php');
}
}
app/Console/Commands/ OverdueTasksNotifier.php : app / Console / Commands / OverdueTasksNotifier.php :
class OverdueTasksNotifier extends Command
{
protected $signature = 'notify:overduetasks';
protected $description = 'Sends alerts (email, sms) for un-Ready overdue tasks.';
public function __construct()
{
parent::__construct();
}
public function handle()
{
echo 'test';
}
}
and the cronlog.txt has: 并且cronlog.txt具有:
[ErrorException]
Invalid argument supplied for foreach()
Content-type: text/html; charset=UTF-8
and above text repeats every minute. 以上文字每分钟重复一次。
I ran php artisan list
and it lists the added command above which is notify:overduetasks
. 我运行了
php artisan list
,它列出了上面添加的命令,它是notify:overduetasks
。
Could someone point me where the error is? 有人可以指出我的错误所在吗? I use shared hosting (cPanel).
我使用共享主机(cPanel)。
----- UPDATE ----- -----更新-----
debug
enabled and the laravel.log is: 启用
debug
,并且laravel.log是:
[2017-04-29 21:02:02] local.ERROR: exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /home/serverhostcom/public_html/demo/vendor/symfony/console/Input/ArgvInput.php:284
Stack trace:
#0 /home/serverhostcom/public_html/demo/vendor/symfony/console/Input/ArgvInput.php(284): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/serverhos...', 284, Array)
#1 /home/serverhostcom/public_html/demo/vendor/symfony/console/Application.php(764): Symfony\Component\Console\Input\ArgvInput->hasParameterOption(Array, true)
#2 /home/serverhostcom/public_html/demo/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->configureIO(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/serverhostcom/public_html/demo/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/serverhostcom/public_html/demo/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}
I found it was to be a typo in paths to php and artisan. 我发现这是通向php和artisan的错字。
/usr/local/bin/php /home/[USERNAME]/public_html/artisan schedule:run >> /dev/null 2>&1
Now task scheduler runs properly. 现在,任务计划程序可以正常运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.