php artisan schedule run

Laravel Framework Russian Community

Пролог

Начало работы

Основы архитектуры

Основы

Фронтенд

Безопасность

Копаем глубже

База данных

Eloquent ORM

Тестирование

Официальные пакеты

Планировщик задач

Введение

Раньше вы могли создавать Cron-записи для каждой запланированной задачи на вашем сервере. Но это могло быстро превратиться в рутину, так как планировщик задач больше не находится в системе контроля версий, и вы должны заходить через SSH на свой сервер, чтобы добавить Cron-записи.

Запуск планировщика

При использовании планировщика вам надо добавить на ваш сервер только одну эту Cron-запись. Если вы не знаете, как добавлять Cron-записи на сервер, то можете использовать такой сервис, как Laravel Forge, который может управлять Cron-записями для вас:

Определение планировщика

Команда exec может быть использована для обращения к операционной системе:

Настройки частоты планировщика

Конечно, есть множество вариантов планировщика, которые вы можете назначить на свою задачу:

МетодОписание
->cron(‘* * * * * *’);Запускать задачу по пользовательскому Cron-расписанию
->everyMinute();Запускать задачу каждую минуту
->everyFiveMinutes();Запускать задачу каждые пять минут
->everyTenMinutes();Запускать задачу каждые десять минут
->everyThirtyMinutes();Запускать задачу каждые тридцать минут
->hourly();Запускать задачу каждый час
->hourlyAt(17);Запускать задачу каждый час в 17 минут
->daily();Запускать задачу каждый день в полночь
->dailyAt(’13:00′);Запускать задачу каждый день в 13:00
->twiceDaily(1, 13);Запускать задачу каждый день в 1:00 и 13:00
->weekly();Запускать задачу каждую неделю
->monthly();Запускать задачу каждый месяц
->monthlyOn(4, ’15:00′);Запускать задачу 4 числа каждого месяца в 15:00
->quarterly();Запускать задачу раз в квартал
->yearly();Запускать задачу каждый год
->timezone(‘America/New_York’);Задать часовой пояс

Эти методы могут быть объединены с дополнительными ограничениями для создания ещё более гибкого планировщика, который будет работать только в определённые дни недели. Например, чтобы запланировать команду на еженедельный запуск в понедельник:

Ниже приведён список дополнительных ограничений расписания:

Ограничение промежутком времени

Методом between можно ограничить выполнение задачи в зависимости от времени дня:

А методом unlessBetween можно исключить выполнение задачи в указанный период времени:

Ограничение проверкой на истинность

Предотвращение перекрытий задач

По умолчанию, запланированные задачи будут запускаться, даже если предыдущий экземпляр задачи всё ещё выполняется. Чтобы предотвратить это, вы можете использовать метод withoutOverlapping :

В этом примере Artisan-команда emails:send будет запускаться каждую минуту, если она ещё не запущена. Метод withoutOverlapping особенно полезен, если у вас есть задачи, которые изменяются коренным образом во время своего выполнения, что мешает вам предсказывать точно, сколько времени данная задача будет выполняться.

Режим обслуживания

Запланированные задачи Laravel не будут выполняться, когда Laravel находится в режиме обслуживания, так как мы не хотим, чтобы выша задачи сешали любом незавершенному обслуживанию, которое вы выполняете на своем сервере. Но если вы хотите, чтобы задача запускалась даже в режиме обслуживания, вы можете использовать метод evenInMaintenanceMode :

Выходные данные задачи

Если вы хотите добавить вывод в указанный файл, вы можете использовать метод appendOutputTo :

Хуки задач

Пинг URL

Использование функций pingBefore($url) или thenPing($url) требует библиотеки Guzzle HTTP. Вы можете добавить Guzzle к вашему проекту с помощью менеджера пакетов Composer:

Источник

Laravel Framework Russian Community

Prologue

Getting Started

Architecture Concepts

The Basics

Frontend

Security

Digging Deeper

Database

Eloquent ORM

Testing

Official Packages

Task Scheduling

Introduction

In the past, you may have generated a Cron entry for each task you needed to schedule on your server. However, this can quickly become a pain, because your task schedule is no longer in source control and you must SSH into your server to add additional Cron entries.

Laravel’s command scheduler allows you to fluently and expressively define your command schedule within Laravel itself. When using the scheduler, only a single Cron entry is needed on your server. Your task schedule is defined in the app/Console/Kernel.php file’s schedule method. To help you get started, a simple example is defined within the method.

Starting The Scheduler

When using the scheduler, you only need to add the following Cron entry to your server. If you do not know how to add Cron entries to your server, consider using a service such as Laravel Forge which can manage the Cron entries for you:

This Cron will call the Laravel command scheduler every minute. When the schedule:run command is executed, Laravel will evaluate your scheduled tasks and runs the tasks that are due.

Defining Schedules

You may define all of your scheduled tasks in the schedule method of the App\Console\Kernel class. To get started, let’s look at an example of scheduling a task. In this example, we will schedule a Closure to be called every day at midnight. Within the Closure we will execute a database query to clear a table:

In addition to scheduling using Closures, you may also use invokable objects. Invokable objects are simple PHP classes that contain an __invoke method:

Scheduling Artisan Commands

In addition to scheduling Closure calls, you may also schedule Artisan commands and operating system commands. For example, you may use the command method to schedule an Artisan command using either the command’s name or class:

Scheduling Queued Jobs

The job method may be used to schedule a queued job. This method provides a convenient way to schedule jobs without using the call method to manually create Closures to queue the job:

Scheduling Shell Commands

The exec method may be used to issue a command to the operating system:

Schedule Frequency Options

There are a variety of schedules you may assign to your task:

MethodDescription
->cron(‘* * * * *’);Run the task on a custom Cron schedule
->everyMinute();Run the task every minute
->everyTwoMinutes();Run the task every two minutes
->everyThreeMinutes();Run the task every three minutes
->everyFourMinutes();Run the task every four minutes
->everyFiveMinutes();Run the task every five minutes
->everyTenMinutes();Run the task every ten minutes
->everyFifteenMinutes();Run the task every fifteen minutes
->everyThirtyMinutes();Run the task every thirty minutes
->hourly();Run the task every hour
->hourlyAt(17);Run the task every hour at 17 minutes past the hour
->everyTwoHours();Run the task every two hours
->everyThreeHours();Run the task every three hours
->everyFourHours();Run the task every four hours
->everySixHours();Run the task every six hours
->daily();Run the task every day at midnight
->dailyAt(’13:00′);Run the task every day at 13:00
->twiceDaily(1, 13);Run the task daily at 1:00 & 13:00
->weekly();Run the task every sunday at 00:00
->weeklyOn(1, ‘8:00’);Run the task every week on Monday at 8:00
->monthly();Run the task on the first day of every month at 00:00
->monthlyOn(4, ’15:00′);Run the task every month on the 4th at 15:00
->lastDayOfMonth(’15:00′);Run the task on the last day of the month at 15:00
->quarterly();Run the task on the first day of every quarter at 00:00
->yearly();Run the task on the first day of every year at 00:00
->timezone(‘America/New_York’);Set the timezone

These methods may be combined with additional constraints to create even more finely tuned schedules that only run on certain days of the week. For example, to schedule a command to run weekly on Monday:

Below is a list of the additional schedule constraints:

Day Constraints

The days method may be used to limit the execution of a task to specific days of the week. For example, you may schedule a command to run hourly on Sundays and Wednesdays:

Between Time Constraints

The between method may be used to limit the execution of a task based on the time of day:

Similarly, the unlessBetween method can be used to exclude the execution of a task for a period of time:

Truth Test Constraints

Environment Constraints

The environments method may be used to execute tasks only on the given environments:

Timezones

Using the timezone method, you may specify that a scheduled task’s time should be interpreted within a given timezone:

If you are assigning the same timezone to all of your scheduled tasks, you may wish to define a scheduleTimezone method in your app/Console/Kernel.php file. This method should return the default timezone that should be assigned to all scheduled tasks:

Remember that some timezones utilize daylight savings time. When daylight saving time changes occur, your scheduled task may run twice or even not run at all. For this reason, we recommend avoiding timezone scheduling when possible.

Preventing Task Overlaps

By default, scheduled tasks will be run even if the previous instance of the task is still running. To prevent this, you may use the withoutOverlapping method:

In this example, the emails:send Artisan command will be run every minute if it is not already running. The withoutOverlapping method is especially useful if you have tasks that vary drastically in their execution time, preventing you from predicting exactly how long a given task will take.

If needed, you may specify how many minutes must pass before the «without overlapping» lock expires. By default, the lock will expire after 24 hours:

Running Tasks On One Server

If your application is running on multiple servers, you may limit a scheduled job to only execute on a single server. For instance, assume you have a scheduled task that generates a new report every Friday night. If the task scheduler is running on three worker servers, the scheduled task will run on all three servers and generate the report three times. Not good!

To indicate that the task should run on only one server, use the onOneServer method when defining the scheduled task. The first server to obtain the task will secure an atomic lock on the job to prevent other servers from running the same task at the same time:

Background Tasks

By default, multiple commands scheduled at the same time will execute sequentially. If you have long-running commands, this may cause subsequent commands to start much later than anticipated. If you would like to run commands in the background so that they may all run simultaneously, you may use the runInBackground method:

The runInBackground method may only be used when scheduling tasks via the command and exec methods.

Maintenance Mode

Laravel’s scheduled tasks will not run when Laravel is in maintenance mode, since we don’t want your tasks to interfere with any unfinished maintenance you may be performing on your server. However, if you would like to force a task to run even in maintenance mode, you may use the evenInMaintenanceMode method:

Task Output

The Laravel scheduler provides several convenient methods for working with the output generated by scheduled tasks. First, using the sendOutputTo method, you may send the output to a file for later inspection:

If you would like to append the output to a given file, you may use the appendOutputTo method:

Using the emailOutputTo method, you may e-mail the output to an e-mail address of your choice. Before e-mailing the output of a task, you should configure Laravel’s e-mail services:

If you only want to e-mail the output if the command fails, use the emailOutputOnFailure method:

Task Hooks

Using the before and after methods, you may specify code to be executed before and after the scheduled task is complete:

The onSuccess and onFailure methods allow you to specify code to be executed if the scheduled task succeeds or fails:

Pinging URLs

Using the pingBefore and thenPing methods, the scheduler can automatically ping a given URL before or after a task is complete. This method is useful for notifying an external service, such as Laravel Envoyer, that your scheduled task is commencing or has finished execution:

The pingBeforeIf and thenPingIf methods may be used to ping a given URL only if the given condition is true :

The pingOnSuccess and pingOnFailure methods may be used to ping a given URL only if the task succeeds or fails:

All of the ping methods require the Guzzle HTTP library. You can add Guzzle to your project using the Composer package manager:

Источник

Планировщик задач

Введение

Раньше вы могли создавать Cron-записи для каждой запланированной задачи на вашем сервере. Но это могло быстро превратиться в рутину, так как планировщик задач больше не находится в системе контроля версий, и вы должны заходить через SSH на свой сервер, чтобы добавить Cron-записи.

Запуск планировщика

При использовании планировщика вам надо добавить на ваш сервер только одну эту Cron-запись. Если вы не знаете, как добавлять Cron-записи на сервер, то можете использовать такой сервис, как Laravel Forge, который может управлять Cron-записями для вас:

Определение планировщика

Команда PHP exec () может быть использована для обращения к операционной системе:

Настройки частоты планировщика

Конечно, есть множество вариантов планировщика, которые вы можете назначить на свою задачу:

МетодОписание
->cron(‘* * * * *’);Запускать задачу по пользовательскому расписанию
->everyMinute();Запускать задачу каждую минуту
->everyFiveMinutes();Запускать задачу каждые 5 минут
->everyTenMinutes();Запускать задачу каждые 10 минут
->everyThirtyMinutes();Запускать задачу каждые 30 минут
->hourly();Запускать задачу каждый час
->hourlyAt(17);Запускать задачу каждый час в хх:17 минут (для версии 5.3 и выше)
->daily();Запускать задачу каждый день в полночь
->dailyAt(’13:00′);Запускать задачу каждый день в 13:00
->twiceDaily(1, 13);Запускать задачу каждый день в 1:00 и 13:00
->weekly();Запускать задачу каждую неделю
->monthly();Запускать задачу каждый месяц
->monthlyOn(4, ’15:00′);Запускать задачу 4 числа каждого месяца в 15:00 (для версии 5.2 и выше)
->quarterly();Запускать задачу каждые 3 месяца (для версии 5.2 и выше)
->yearly();Запускать задачу каждый год
->timezone(‘America/New_York’);Задать часовой пояс (для версии 5.2 и выше)

Эти методы могут быть объединены с дополнительными ограничениями для создания ещё более гибкого планировщика, который будет работать только в определённые дни недели. Например, чтобы запланировать команду на еженедельный запуск в понедельник:

Ниже приведён список дополнительных ограничений в расписании:

Ограничение промежутком времени

Методом PHP between () можно ограничить выполнение задачи в зависимости от времени дня:

А методом PHP unlessBetween () можно исключить выполнение задачи в указанный период времени:

Ограничения успешного теста

Предотвращение перекрытий задач

По умолчанию, запланированные задачи будут запускаться, даже если предыдущий экземпляр задачи всё ещё выполняется. Чтобы предотвратить это, вы можете использовать метод PHP withoutOverlapping () :

В этом примере Artisan-команда sh emails:send будет запускаться каждую минуту, если она ещё не запущена. Метод PHP withoutOverlapping () особенно полезен, если у вас есть задачи, которые изменяются коренным образом во время своего выполнения, что мешает вам предсказывать точно, сколько времени данная задача будет выполняться.

Режим обслуживания

Запланированные задачи Laravel не будут запускаться, когда Laravel находится в режиме обслуживания, так как мы не хотим, чтобы ваши команды столкнулись с какими-либо незаконченными операциями обслуживания сервера. Но если вы хотите, чтобы задача запускалась даже в режиме обслуживания, вы можете использовать метод PHP evenInMaintenanceMode () :

Выходные данные задачи

Если вы хотите добавить вывод в указанный файл, вы можете использовать метод PHP appendOutputTo () :

Обработчики прерываний задач

Пинг URL-адресов

Вы можете добавить Guzzle к вашему проекту с помощью менеджера пакетов Composer:

Вы можете добавить Guzzle к вашему проекту, добавив следующую строку в файл composer.json :

Комментарии (10)

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

Всем привет! У вас заработал крон? Я делаю так:

Но у меня не работает почему то на Debian 7.8, что я делаю не так?

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

В статье >> стало кавычками, посмотри внимательно на свой код.

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

это не то что я ищу, тут нарыл (точнее один умный человек сказал), что под рутом вообще нельзя ничего запускать никогда, так что в etc/crontab добавлять не вариант

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

В crontab указывается пользователь (после звездочек), обычно это www-data, см. конфиг Apache/nginx/php, какой там пользователь.

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

у меня Debian там пишу так /var/spool/cron/crontab/fileusername и тут без указание пользователя, проблема следующая, которая ниже в комменте

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

Для виндовса (например если тестирование на локалке на винде проходит)

This is possible with Windows Task Scheduler but the downside is the lowest it can be set to is Every 5 Minutes which is still ok for a testing environment.
I created a batch file scheduler.bat with the following contents

Change directorys to match your setup. My project root is cw5
If you have php successfully added to your PATH variable then the second line can read php artisan. no need for an exact location. But you will need to make sure you cd to your project root first.
Then launch the task scheduler Windows Key + R then paste in Taskschd.msc and hit enter.
Then click Create Basic Task on the right in the Actions pane.
Name your task something so you will know what it is for if you need to modify it or are running multiple projects then click Next.
Leave this page set to Daily for now and click Next.
Leave this page as defaults as well and click Next.
Make sure Start a Program is selected and click Next.
Browse to the batch file we just created and then click Next then click Finish.
Now, select Task Scheduler Library on the left, and find your task in the middle pane and right-click and click Properties
Go to the Triggers tab, click Daily in the list and click Edit.
The drop-down at the top next to Begin the task change to At Log on for Any user
Check the box that says Repeat Task Every and choose 5 Minutes from the drop-down. The drop-down after for a duration: on the same line choose Indefinitely.
Click OK. Done.
Then right-click on your task in the middle pane and click Run to initiate it.

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

А задачи 1, 2 и т.д. будут выполняться синхронно или асинхронно?
Задача 1 дожидается выполнения задачи 2?

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

на крон выдет ошибку
Undefined variable: boundary

запускаю очистку кеша php artisan cache:clear

[ErrorException]
Undefined variable: boundary

php artisan schedule run. Смотреть фото php artisan schedule run. Смотреть картинку php artisan schedule run. Картинка про php artisan schedule run. Фото php artisan schedule run

эта проблема решена — теперь
Running scheduled command: Closure

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class ‘App\Task’ not found

Источник

php artisan schedule:run does not work in windows #7868

Comments

uwascan commented Mar 4, 2015

I am trying out the new command scheduling feature of Laravel 5 on windows 7 using a windows based cron service [http://www.intelliadmin.com/index.php/2011/11/cron-service-for-windows/]. When I discovered that my commands where not running I ran php artisan schedule:run manually on a console and got the following error: Running scheduled command: C:\Program Files (x86)\PHP\v5.6\php.exe artisan roman:inspire > /dev/null 2>&1 &
The system cannot find the path specified.
I think the problem is with ‘> /dev/null 2>&1 &’ appended to the command. Is it possible for laravel not to append ‘> /dev/null 2>&1 &’ when running on windows, if not what do you suggest I do. I have an up coming project that depends on the command scheduling feature of Laravel 5.
Any guidiance will be appreciated.

The text was updated successfully, but these errors were encountered:

We are unable to convert the task to an issue at this time. Please try again.

The issue was successfully created but we are unable to update the comment at this time.

GrahamCampbell commented Mar 4, 2015

This is known, yeh. Looks like windows isn’t supported.

crynobone commented Mar 4, 2015

uwascan commented Mar 5, 2015

my scheduled jobs are running now. this is a terrible thing to do I know, it will remain so until I come across a better solution.

uwascan commented Mar 5, 2015

Is there any best practice on how to extend or replace Illuminate\Console\Scheduling\Event.php?

uwascan commented Mar 5, 2015

@GrahamCampbell your response is not good enough, are you saying windows users should avoid Laravel?

neomerx commented Mar 5, 2015

@uwascan you’re right on your way to make a pull request to Laravel however manipulation is a surplus

btw why running PHP on windows servers these days?

uwascan commented Mar 5, 2015

From the link posted by @crynobone, I was able to make it work on windows using
php artisan schedule:run > NUL 2>&1

crynobone commented Mar 5, 2015

btw why running PHP on windows servers these days?

Someone/team could consider http://azure.microsoft.com/en-us/, unless Laravel team has decided not to support Windows.

uwascan commented Mar 5, 2015

@neomerx my client only has windows based infrastructure. I think PHP support on windows is not as bad as it is portrayed to be. What would you do if you are hired by a windows shop to build a php app? reject the offer or force linux? I find Linux very good though, I am still wrapping my head around it.

neomerx commented Mar 5, 2015

neomerx commented Mar 5, 2015

uwascan commented Mar 5, 2015

The project I am working is used internally on a private LAN. I submitted a pull request a few hours ago. My very first. #7887

uwascan commented Mar 7, 2015

Another simple way to make this work on windows without changing Laravel code is to append the following to your sheduler code

the code below works on windows when sending output to a file.

This is what I am currently using and all is good so far. I think this should be added to the docs.

gregrobson commented May 7, 2015

dnetix commented May 25, 2015

Why is this issue closed, still not fixed. I am just removing the «2>&1 &» string from the Laravel code but it’s not a good solution. And the modification to the Laravel code should not be so hard. Just put a conditional if the server OS is windows do not append that string. I prefer linux servers, always, but you cannot ask to a client to change all his infrastructure.

Tropicalista commented Aug 21, 2015

cvlug commented Nov 25, 2015

The solution on https://laracasts.com/discuss/channels/general-discussion/running-schedulerun-on-windows does not work for me: nothings happens.
I tried uwascan solution.
In taskplanner, in field Program/script, i put: php
In field Add arguments, i put: D:\phpsites\touristpreview\laravel\artisan schedule:run > NUL 2>&1
In log files i then see:

[2015-11-25 16:00:19] local.ERROR: exception ‘RuntimeException’ with message ‘Too many arguments.’ in D:\phpsites\touristpreview\laravel\vendor\symfony\console\Input\ArgvInput.php:177
Stack trace:
#0 D:\phpsites\touristpreview\laravel\vendor\symfony\console\Input\ArgvInput.php(86): Symfony\Component\Console\Input\ArgvInput->parseArgument(‘>’)
#1 D:\phpsites\touristpreview\laravel\vendor\symfony\console\Input\Input.php(61): Symfony\Component\Console\Input\ArgvInput->parse()
#2 D:\phpsites\touristpreview\laravel\vendor\symfony\console\Command\Command.php(221): Symfony\Component\Console\Input\Input->bind(Object(Symfony\Component\Console\Input\InputDefinition))
#3 D:\phpsites\touristpreview\laravel\vendor\laravel\framework\src\Illuminate\Console\Command.php(136): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 D:\phpsites\touristpreview\laravel\vendor\symfony\console\Application.php(838): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 D:\phpsites\touristpreview\laravel\vendor\symfony\console\Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Console\Scheduling\ScheduleRunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 D:\phpsites\touristpreview\laravel\vendor\symfony\console\Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 D:\phpsites\touristpreview\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 D:\phpsites\touristpreview\laravel\artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9

Anybody please have a solution?

DarioCorno commented Mar 15, 2016

I’m actually using Windows 10, and it works if the batch file is written like this :

php artisan schedule:run 1>> NUL 2>&1

also redirectin ghte output to some sort of log works fine

php artisan schedule:run >> schedule_logs.log

javedLive commented Aug 22, 2016 •

@DarioCorno How did you create the batch file and where did you put that?

The I have run the following command in my cmd to create the task in schedule:

schtasks /create /sc minute /mo 1 /tn «PHP Cron Job» /tr C:\xampp\htdocs\blog\cron.bat

It said PHP cron job crated successfully.

But nothing happened it every minute. Can you please explain how did you do it?

bradleyy1012 commented Sep 24, 2016

hey everyone! i just solved this on my server! try using the absolute path to php!!
/usr/local/bin/php /path/to/artisan schedule:run >> /dev/null 2>&1

javedLive commented Sep 24, 2016

You tried for Windows?

taproot9 commented Mar 6, 2017 •

make a batch file

:loop
cd C:\xampp\htdocs\your_app
C:\xampp\php\php.exe artisan schedule:run 1>> NUL 2>&1
goto loop

ghost commented May 4, 2017

cd c:\Users\User\Desktop\alerts
C:\wamp64\bin\php\php7.0.10\php.exe artisan schedule:run 1>> NUL 2>&1

The schedule function in the Kernel.php looks like this:

And the actual task that will be called looks like this

public function handle()
<
echo ‘Hello’;
>

It doesn’t give any output. I should automatically print «Hello» after a minute right?
But it doesn’t.
Also just to confirm this output will be shown in the cmd prompt under my laravel project directory right?

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *