Magento – Cron causing high CPU

Apache2magento2php-7

Our /var/log/messages is flooded with these records:

Jan 25 13:17:04 885589-DB1 systemd: Starting Session 570175 of user apache.

Which causes high CPU process:

1858 root      20   0  345084 315516   1392 R  95.1  0.5   7696:47 systemd-logind

Caused by these in the crontab:

* * * * * /usr/bin/php /var/www/vhosts/html/site/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/vhosts/html/site/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/vhosts/html/site/update/cron.php >> /var/www/vhosts/html/site/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/vhosts/html/site/bin/magento setup:cron:run >> /var/www/vhosts/html/site/var/log/setup.cron.log

If I comment out the jobs, it stops.
Any ideas why these cronjobs are launching a lot of apache sessions?

Server version: Apache/2.4.6 (CentOS)

PHP 7.0.27 (cli) (built: Jan 4 2018 13:39:07) ( NTS )

Magento 2.1.10 – 2.2.2

EDIT

I apologize, priorities took me away. The issue has disappeared for unknown reasons. Most likely a 3rd party module has been updated.

Best Answer

Try to disable all of your custom cron jobs, then enable it one by one and see which one is guilty - then inspect it's code.

Funny thing that CLI script causes huge web server load. Does any of your cron jobs is making connection with any website on the same server? E.g. using curl, webapi?

Related Topic