Magento – Reindex gets scheduled by cron but never executed

cronindexmagento2reindex

For magento 2.2.4 my cron.sh looks like this (crontab is not available in this environment):

#!/bin/bash

PHP_BIN=`which php7-71STABLE-CLI`;

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BIN="$DIR/bin/magento"
INI="$DIR/php.ini"

$PHP_BIN -d max_execution_time=180 -d memory_limit=756M -c $INI $BIN cron:run | grep -v "Ran jobs by schedule" >> $DIR/var/log/magento.cron.log
$PHP_BIN -d max_execution_time=180 -d memory_limit=756M -c $INI $DIR/update/cron.php >> $DIR/var/log/update.cron.log
$PHP_BIN -d max_execution_time=180 -d memory_limit=756M -c $INI $BIN setup:cron:run >> $DIR/var/log/setup.cron.log

It is run every minute and produces no errors.

In the table cron_schedule I see all kinds of scheduled entries including indexer_reindex_all_invalid.

While others are properly executed the reindex never gets executed. It is stuck with status pending.

The cron config in backend is using the default options.

Manual php bin/magento indexer:reindex works fine but this should be done automatically as it is in my dev environment.

I googled and searched everywhere and ran out of options. What could possibly be wrong here?

Best Answer

I finally found the solution. The crons in the magento backend were configured to use a separate process which does not work on our provider's server. Once I disabled that option the indexers were flying again.

Related Topic