diff --git a/lib/internal/Magento/Framework/Crontab/CrontabManager.php b/lib/internal/Magento/Framework/Crontab/CrontabManager.php
index 4c22a8ccb01dc64f544c2da9b012d2b904ac6324..a60bd9d2cb512ac0000941657e76db1f0be20b85 100644
--- a/lib/internal/Magento/Framework/Crontab/CrontabManager.php
+++ b/lib/internal/Magento/Framework/Crontab/CrontabManager.php
@@ -133,7 +133,7 @@ class CrontabManager implements CrontabManagerInterface
private function cleanMagentoSection($content)
{
$content = preg_replace(
- '!' . self::TASKS_BLOCK_START . '.*?' . self::TASKS_BLOCK_END . PHP_EOL . '!s',
+ '!' . preg_quote(self::TASKS_BLOCK_START) . '.*?' . preg_quote(self::TASKS_BLOCK_END . PHP_EOL) . '!s',
'',
$content
);
@@ -190,7 +190,7 @@ class CrontabManager implements CrontabManagerInterface
*/
private function checkSupportedOs()
{
- if (stripos(PHP_OS, 'WIN') !== false) {
+ if (stripos(PHP_OS, 'WIN') === 0) {
throw new LocalizedException(
new Phrase('Your operation system is not supported, you cannot work with crontab')
);