Skip to content

Commit

Permalink
MAGETWO-85274: Update CrontabManager.php #12610
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Korshenko authored Dec 12, 2017
2 parents d91b5c3 + d134cc4 commit 043e32a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/internal/Magento/Framework/Crontab/CrontabManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public function removeTasks()
private function generateSection($content, $tasks = [])
{
if ($tasks) {
// Add EOL symbol to previous line if not exist.
if (substr($content, -strlen(PHP_EOL)) !== PHP_EOL) {
$content .= PHP_EOL;
}

$content .= $this->getTasksBlockStart() . PHP_EOL;
foreach ($tasks as $task) {
$content .= $task['expression'] . ' ' . PHP_BINARY . ' ' . $task['command'] . PHP_EOL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,17 @@ public function saveTasksDataProvider()
. ' %% cron:run | grep -v \"Ran \'jobs\' by schedule\"' . PHP_EOL
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
],
[
'tasks' => [
['command' => '{magentoRoot}run.php % cron:run | grep -v "Ran \'jobs\' by schedule"']
],
'content' => '* * * * * /bin/php /var/www/cron.php',
'contentToSave' => '* * * * * /bin/php /var/www/cron.php' . PHP_EOL
. CrontabManagerInterface::TASKS_BLOCK_START . ' ' . md5(BP) . PHP_EOL
. '* * * * * ' . PHP_BINARY . ' /var/www/magento2/run.php'
. ' %% cron:run | grep -v \"Ran \'jobs\' by schedule\"' . PHP_EOL
. CrontabManagerInterface::TASKS_BLOCK_END . ' ' . md5(BP) . PHP_EOL,
],
];
}
}

0 comments on commit 043e32a

Please sign in to comment.