如何在Laravel 5.6中将Cron条目添加到WAMP本地主机 [英] How to add Cron entries to WAMP localhost in Laravel 5.6

查看:57
本文介绍了如何在Laravel 5.6中将Cron条目添加到WAMP本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在我的应用程序中的laravel 5.6中创建任务表.我正在使用Windows 7 OS,我的本地主机是WAMP.在laravel文档中,将添加到您的服务器中的Cron条目

  * * * * * cd/您的项目路径&&php artisan schedule:run>>/dev/null 2>& 1 

但是我对如何使用My wamp localhost添加Cron条目一无所知.我的laravel文件在桌面名称中为 schoolproject ,那么如何在Wamp中添加Cron条目?

解决方案

对于运行本地WAMP服务器且计算机并不总是苏醒的人

过去两个月中,我一直在寻找最有效的方法.

首先,将 Kernel 类和控制台命令设置为

在触发器"部分中,您可以这样设置:

该操作应该是在WAMP文件夹中运行PHP可执行文件(使用 artisan schedule:run )作为参数:

,但这与

然后在其设置"标签中,选择错过计划的开始后尽快运行任务":

因此,即使您的计算机在此任务的计划时间关闭或处于睡眠状态,Windows也将知道在唤醒后立即运行该任务.

I am going to create Task Shedule in laravel 5.6 in my app. I am working with windows 7 os and my localhost is WAMP. in laravel documentation there is add Cron entries to your server as

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

but I have not any idea about how to add Cron entries with My wamp localhost. my laravel file is in the desktop name as schoolproject then how can add Cron entries with my wamp?

解决方案

For people who run a local WAMP server and their computer isn't always awake

I spent the past couple months figuring out what would work best.

First, set up your Kernel class and console commands as instructed in the Laravel docs.

In Windows, open Task Scheduler, and create a new task:

In the Triggers section, you can set it like this:

The action should be to run the PHP executable within your WAMP folder (using artisan schedule:run) as the argument:

But then here is an important difference from other tutorials I've seen:

For any tasks that are critical, you'll want to treat them separately.

For example, let's assume you have a task that backs up your database, and you'd like to run this every single day at noon, so your Kernel class has this command in its schedule.

But then you realize a flaw in this approach: if you were out at lunch a few days in a row and left your computer asleep, that noon task would have been missed, and now your backups would be quite stale.

So, remove that daily database backups command from the schedule in Kernel, and instead, then create a second task within Windows Task Scheduler, and set the trigger like:

Then in its Settings tab, you can choose "Run task as soon as possible after a scheduled start is missed":

Therefore, even if your computer is off or asleep at this task's scheduled time, Windows will know to run the task immediately upon waking.

这篇关于如何在Laravel 5.6中将Cron条目添加到WAMP本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆