Laravel 5.4任务计划程序

编程入门 行业动态 更新时间:2024-10-27 17:21:07
本文介绍了Laravel 5.4任务计划程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经根据Laravel 5.4文档安装了调度程序.但这不起作用.

I have setup scheduler according to the Laravel 5.4 documentation. But it doesn't work.

我的日常工作是:

* * * * * 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'; } }

和 cronlog.txt 具有:

[ErrorException] Invalid argument supplied for foreach() Content-type: text/html; charset=UTF-8

及以上文字每分钟重复一次.

and above text repeats every minute.

我运行了php artisan list,它列出了添加的命令,上面是notify:overduetasks.

I ran php artisan list and it lists the added command above which is notify:overduetasks.

有人可以指出我的错误所在吗?我使用共享主机(cPanel).

Could someone point me where the error is? I use shared hosting (cPanel).

-----更新-----

debug且laravel.log为:

debug enabled and the laravel.log is:

[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}

推荐答案

我发现这是通向php和artisan的错字.

I found it was to be a typo in paths to php and artisan.

/usr/local/bin/php /home/[USERNAME]/public_html/artisan schedule:run >> /dev/null 2>&1

现在任务计划程序可以正常运行.

Now task scheduler runs properly.

更多推荐

Laravel 5.4任务计划程序

本文发布于:2023-11-13 12:23:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584350.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计划   程序   Laravel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!