Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "php artisan schedule:run" compatible with Windows #9524

Closed
FranArjona opened this issue Jul 4, 2015 · 6 comments
Closed

Make "php artisan schedule:run" compatible with Windows #9524

FranArjona opened this issue Jul 4, 2015 · 6 comments

Comments

@FranArjona
Copy link
Contributor

I apologize first of all, because I have seen #7868, but it was closed and still not fixed. So I wanted to propose an easy solution.

Context:

When I run "php artisan schedule:run" (in Windows 7 in my case), a path error is thrown due to the use of /dev/null as the default output property in Illuminate\Console\Scheduling\Event.php:

public $output = '/dev/null';

So I have to change every scheduled command in my App\Console\Kernel.php Schedule method:

$default_output = (strpos(strtoupper(PHP_OS), 'WIN')===0) ? 'NUL' : '/dev/null';

$schedule->command('test:foo')
    ->daily()
    ->sendOutputTo($default_output);

Possible Solution:

Could it be done something similar in the Event constructor to make CRON Jobs fully compatible with Windows? This could it be a possibility (not fully tested):

/**
 * Create a new event instance.
 *
 * @param  string  $command
 * @return void
 */
public function __construct($command)
{
    $this->command = $command;
    $this->output = (strpos(strtoupper(PHP_OS), 'WIN')===0) ? 'NUL' : '/dev/null';
}

And update other related methods such as public function emailOutputTo($addresses).

I don't know if there are any side effects, but I think it shouldn't be ignored only for being a Windows matter.

@tortuetorche
Copy link
Contributor

@GrahamCampbell Duplicate ? Won't Fix ?

@GrahamCampbell
Copy link
Member

We're open to PRs if you want this. :)

@tortuetorche
Copy link
Contributor

@GrahamCampbell I don't use Laravel Scheduler yet in my projects.
But if I need it, I will.

@FranArjona
Copy link
Contributor Author

@GrahamCampbell I have done a PR #9573 to fix it :). Now scheduler works fine for me in Windows 7

@GrahamCampbell
Copy link
Member

Great, thanks. :)

@tortuetorche
Copy link
Contributor

@FranArjona 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants