Skip to content

Scheduler buildBackgroundCommand appends the output for schedule:finish to $event->getDefaultOutput() on non windows #50081

Closed
@ghost

Description

Laravel Version

10.4.1

PHP Version

8.1.4

Database Driver & Version

Mysql 8

Description

Hi,

https://github.com/laravel/framework/blob/84e7f85769ea268ffec9acab30f7a826223b3d6f/src/Illuminate/Console/Scheduling/CommandBuilder.php#L54C8-L61C11

   if (windows_os()) {
        return 'start /b cmd /v:on /c "('.$event->command.' & '.$finished.' ^!ERRORLEVEL^!)'.$redirect.$output.' 2>&1"';
    }

    return $this->ensureCorrectUser($event,
        '('.$event->command.$redirect.$output.' 2>&1 ; '.$finished.' "$?") > '
        .ProcessUtils::escapeArgument($event->getDefaultOutput()).' 2>&1 &'
    );

should be

    if (windows_os()) {
        return 'start /b cmd /v:on /c "('.$event->command.' & '.$finished.' ^!ERRORLEVEL^!)'.$redirect.$output.' 2>&1"';
    }

    return $this->ensureCorrectUser($event,
        '('.$event->command.$redirect.$output.' 2>&1 ; '.$finished.' "$?") ' . $redirect . $output . ' 2>&1 &'
    );

Steps To Reproduce

Run a background scheduled command defined like this:

->runInBackground()->sendOutputTo('/dev/stdout')

and check the logs for

Running scheduled command: ('/usr/local/bin/php' 'artisan' {command signature} > '/dev/stdout' 2>&1 ; '/usr/local/bin/php' 'artisan' schedule:finish "framework/schedule-{random}" "$?") > '/dev/null' 2>&1 &

If the log channel is set to stdout, the command will log nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions