0

I use a shared hosting service and installed Magento 2.2.1 through a one-click installer in my host's control panel. After installation, I immediately saw the error: One or more indexers are invalid. Make sure your Magento cron job is running.

In an attempt to repair this error, I created cronjobs in the Cronjobs Settings of my hosting control panel, using the three commands listed in the documentation: http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html (edited for privacy)

* * * * * | /usr/local/php7/bin/php /home/www/WEBSITE.com/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /home/www/WEBSITE.com/var/log/magento.cron.log
* * * * * | /usr/local/php7/bin/php /home/www/WEBSITE.com/update/cron.php >> /home/www/WEBSITE.com/var/log/update.cron.log  
* * * * * | /usr/local/php7/bin/php /home/www/WEBSITE.com/bin/magento setup:cron:run >> /home/www/WEBSITE.com/var/log/setup.cron.log

Not long thereafter, I started being inundating with emails of the following error:

Cron: '/usr/local/php7/bin/php /home/www/WEBSITE.com/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /home/www/WEBSITE.com/var/log/magento.cron.log'

[Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [1226] User 'DB_NAME' has exceeded the 'max_user_connections' resource (current value: 20)
[PDOException]
SQLSTATE[HY000] [1226] User 'DB_NAME' has exceeded the 'max_user_connections' resource (current value: 20)
cron:run [--group GROUP] [--bootstrap BOOTSTRAP]

To fix this error, I contacted the hosting provider's tech support, who then told me that max_user_connections is hard-coded on shared plans at 20 and it could not be altered.

This led me to go back through the documentation listed above and follow the steps in the Prerequisites, but as I do not have root access to the server, (since I'm on a shared hosting plan) I can not run commands like

crontab -u magento_user -e

So at this point I'm just lost. I'm unsure of what to do to make this work. I am still new to site administration and Magento so maybe there's something obvious I'm missing.

1 Answer 1

0

For the first error you described that is One or more indexers are invalid. Make sure your Magento cron job is running.

Go to you Magento root category & fire this command from your magento root directory

php bin/magento indexer:reindex

& for setting the cron error just fire these three commands into your terminal/cmd from your Magento root directory

php bin/magento cron:run

php update/cron.php

php bin/magento setup:cron:run

If still facing any issue feel free to do revert back

9
  • When I run either command, I get this error: Deprecated: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0 Parse error: syntax error, unexpected '[', expecting ')' in /home/www/WEBSITE.com/bin/magento on line 21.
    – k.x
    Commented Dec 13, 2017 at 19:04
  • 1
    You need to upgrade your php version from 5.3 to 7 so it will not show that error & then perform the above commands Commented Dec 13, 2017 at 19:07
  • 1
    I have already had it set to PHP 7 for a while now. Checked again just now and confirmed that's what it's at.
    – k.x
    Commented Dec 13, 2017 at 19:30
  • Now it is showing what, the same error? Commented Dec 13, 2017 at 19:32
  • Yes, I didn't make any change. It was set to PHP 7 to begin with.
    – k.x
    Commented Dec 13, 2017 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.