-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathSystem.php
executable file
·69 lines (49 loc) · 1.03 KB
/
System.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Sid\Phalcon\Cron\Job;
use Sid\Phalcon\Cron\Job;
class System extends Job
{
/**
* @var string
*/
protected $command;
/**
* @var string
*/
protected $output;
public function __construct(string $expression, string $command, string $output = null)
{
parent::__construct($expression);
$this->command = $command;
$this->output = $output;
}
public function getCommand() : string
{
return $this->command;
}
/**
* @return string|null
*/
public function getOutput()
{
return $this->output;
}
private function buildCommand() : string
{
$command = $this->getCommand();
$output = $this->getOutput();
if ($output) {
$command .= " > " . $output . " 2>&1";
}
return $command;
}
/**
* @return string|null
*/
public function runInForeground()
{
return shell_exec(
$this->buildCommand()
);
}
}