Laravel 5.1任务调度在Windows

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

我试图让Laravel 5.1的任务调度在IIS上工作。当我使用Windows任务管理器运行一个批处理文件,它将运行任务一次。我怎样才能得到? - > everyMinute()工作

Windows批处理文件:

CD C:\\的Inetpub \\ MyApp的C:\\ PROGRA〜2 \\ PHP \\ php.exe的工匠时间表:运行1>> NUL 2 - ;&放大器; 1

内核:

类内核扩展​​ConsoleKernel{    保护$命令= [        \\ APP \\控制台\\命令\\ MyCommand ::类,    ];    保护功能表(附表$时间表)    {        $时刻表>指令(测试) - GT; everyMinute();    }}

命令:

公共职能手柄()    {        登录::信息('测试');    }

解决方案

看看在任务调度文档。

  

启动该调度程序

    

下面是你需要添加到您的服务器的唯一cron项:

    

* * * * *的PHP /路径/要/工匠时间表:运行>>的/ dev / null的2 - ;&放大器; 1

    

这cron将会调用Laravel调度命令的每一分钟。然后,Laravel评估您的计划任务和运行到期的任务。

在你的情况,你可以使用Windows任务调度程序,而不是克朗,但最重要的事情是调用工匠时间表:运行的每一分钟。每次运行此命令时,它会检查其调度和运行到期的任务/命令说。

工匠时间表:运行不启动长期运行的过程,直到你杀了它的停留活着的运行任务。正如我所说的,它需要被调用的每一分钟。

I'm trying to get Laravel 5.1 Task Scheduling working on IIS. When I run a batch file using Windows task manager it will run the task one time only. How can I get ->everyMinute() to work?

Windows batch file:

cd c:\inetpub\myapp c:\PROGRA~2\PHP\php.exe artisan schedule:run 1>> NUL 2>&1

The kernel:

class Kernel extends ConsoleKernel { protected $commands = [ \App\Console\Commands\MyCommand::class, ]; protected function schedule(Schedule $schedule) { $schedule->command('test')->everyMinute(); } }

The command:

public function handle() { log::info('test'); }

解决方案

Take a look at the task scheduler doc.

Starting The Scheduler

Here is the only Cron entry you need to add to your server:

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1

This Cron will call the Laravel command scheduler every minute. Then, Laravel evaluates your scheduled tasks and runs the tasks that are due.

In your case, you use the Windows task scheduler instead of Cron but the important thing is to call artisan schedule:run every minute. Each time this command is run, it checks its schedule and runs the due tasks/commands added.

artisan schedule:run does not start a long-running process that stays alive to runs tasks until you kill it. As I said, it needs to be called every minute.

更多推荐

Laravel 5.1任务调度在Windows

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

发布评论

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

>www.elefans.com

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