6

I have just made a fresh installation of Magento 2.2.1 to eventually be able to migrate from my present 1.7.

But I already encountered some difficulties. The message "One or more indexes are invalid. Make sure your Magento cron job is running." is showing in admin.

I tried to google how to get the cron job running but can't find how to do it in cPanel, and I don't understand how to get it running. I do not have SSH access and can't do anything through CLI. Does anybody know how I can get this cron thing set up and working from cPanel?

1

4 Answers 4

5

you can add ssh via cpanel. try this link

after ssh is enabled.you have access to your instance, go to the Magento 2 root directory and run php bin/magento cron:install.

1
  • @Ronnie79 whether your issue is solved.if solved mark as resolved Dec 1, 2017 at 8:43
3

You have to have SSH access to your Magento 2 installation in order to run it as smooth as it should. Make sure, you get the access.

As soon as you have access to your instance, go to the Magento 2 root directory and run php bin/magento cron:install. That should be enough.

In case the only way for you is to add the cron through an admin interface like cpanel; try to add the cron jobs line by line.

* * * * * <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
* * * * * <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

Depending in the admin panel, you might have to enter the path to the PHP binary. If you are not sure which path it is, just try php.

9
  • Oh. Is there no way to do it in cPanel with Cron Job? Our Host doesn't allow SSH access to anyone for security reasons they say. But our host still offer Magento installation in their installatron...
    – Ronnie79
    Nov 22, 2017 at 16:45
  • Are you able to add CronJobs through the cPanel? Nov 22, 2017 at 16:48
  • Can you enter something like * * * * www-data super_cool_command somewhere in cPanel? Nov 22, 2017 at 16:49
  • Yes, I can add a Cron Job in cPanel. One line command and choose if I want it to be run every minute, every hour etc. But don't know what command to write there to make it work...
    – Ronnie79
    Nov 22, 2017 at 17:43
  • Nice! That is exactly what you need. I'll send you the lines in a few hours. Nov 23, 2017 at 6:26
1

try this one Here are the relevant lines in .htaccess (read the comments):

<FilesMatch "^cron.*\.php$">
    ...
</FilesMatch>
0
  1. I think I sorted it out now.
  2. I was not sure if this is the right way but this is how I did it:

I created one cron job that run every minute in my cPanel:

/usr/local/bin/php /home/[my username]/domains/[my domain]/public_html/bin/magento cron:install

Then after one minute when I got an email that this was performed I deleted it and created a new one like this instead:

/usr/local/bin/php /home/[my username]/domains/[my domain]/public_html/bin/magento cron:run

1
  • Or do I also need to add * * * * * <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 as cron jobs?
    – Ronnie79
    Dec 2, 2017 at 9:36

Your Answer

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

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