How to add Cron entries to WAMP localhost in Laravel 5.6

一个人想着一个人 提交于 2021-02-10 06:49:06

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/52314218/how-to-add-cron-entries-to-wamp-localhost-in-laravel-5-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!