Skip to content

Commit 60da5cf

Browse files
author
Florian Eckerstorfer
authored
Merge pull request #17 from bpolaszek/master
Add ability to append output file on UNIX/LINUX systems
2 parents 52d76db + 5032762 commit 60da5cf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/BackgroundProcess.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ public function __construct($command)
5858
*
5959
* @param string $outputFile File to write the output of the process to; defaults to /dev/null
6060
* currently $outputFile has no effect when used in conjunction with a Windows server
61+
* @param bool $append - set to true if output should be appended to $outputfile
6162
*/
62-
public function run($outputFile = '/dev/null')
63+
public function run($outputFile = '/dev/null', $append = false)
6364
{
6465
switch ($this->getOS()) {
6566
case self::OS_WINDOWS:
6667
shell_exec(sprintf('%s &', $this->command, $outputFile));
6768
break;
6869
case self::OS_NIX:
69-
$this->pid = (int)shell_exec(sprintf('%s > %s 2>&1 & echo $!', $this->command, $outputFile));
70+
$this->pid = (int)shell_exec(sprintf('%s %s %s 2>&1 & echo $!', $this->command, ($append) ? '>>' : '>', $outputFile));
7071
break;
7172
default:
7273
throw new RuntimeException(sprintf(

0 commit comments

Comments
 (0)