Magento 2 update.log increases significant size every minute

As far as I know, the var/log/update.log file is used with the cron indeed.

It is declared in \setup\src\Magento\Setup\Model\Cron\Status.php

$this->logFilePath = $logFilePath ? $logFilePath : DirectoryList::LOG . '/update.log';

And then retrieved via the getLogFilePath() method.

If you check where this method is being called, it's under the \setup\src\Magento\Setup\Model\Cron\JobFactory.php :

$logStream = fopen($cronStatus->getLogFilePath(), 'a+');
$streamOutput = new MultipleStreamOutput([$statusStream, $logStream]);

Then the $streamOutput variable is passed as a parameter to the job class, for example:

return new JobUpgrade(
    $this->serviceLocator->get('Magento\Setup\Console\Command\UpgradeCommand'),
    $objectManagerProvider,
    $streamOutput,
    $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
    $cronStatus,
    $name,
    $params
);

If I keep going with this example, the $this->output is used in the execute() method:

$this->command->run(new ArrayInput($this->params), $this->output);

The run() method is declared in vendor\symfony\console\Symfony\Component\Console\Command\Command.php

The $output variable is then used in several places such as :

    $this->initialize($input, $output);

As well as :

    if ($input->isInteractive()) {
        $this->interact($input, $output);
    }

    $input->validate();

    if ($this->code) {
        $statusCode = call_user_func($this->code, $input, $output);
    } else {
        $statusCode = $this->execute($input, $output);
    }

Another interesting one:

        } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
            $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
        }

According to this last code, some stuff can be written in case of very verbose parameter. Maybe you setup your cron jobs with -vv and that's why stuff is getting logged.

This is not a definite answer, but you should follow that stack trace I just gave you to investigate the issue.


You probably set wrong permissions on some folders. /update/cron lists all folders with wrong permissions

Easy way is just comment out in crontab update and setup

#* * * * * <path to php binary> <magento install dir>/update/cron.php >> <magento install dir>/var/log/update.cron.log
#* * * * * <path to php binary> <magento install dir>/bin/magento setup:cron:run >> <magento install dir>/var/log/setup.cron.log

You don't need them if you don't need to update and install from admin panel.

It's dangerous idea for production server. You can manually update via composer on test/local server; test it; then copy updates to production server.

The one you really need is

* * * * * <path to php binary> <magento install dir>/bin/magento cron:run | grep -v "Ran jobs by schedule" >> <magento install dir>/var/log/magento.cron.log

It manages "indexers, sends automated e-mails, generates the sitemap, and so on" - as described in devdocs

Tags:

Cron

Magento2

Log