cancel
Showing results for 
Search instead for 
Did you mean: 

Magento cron job How to. Please help

Magento cron job How to. Please help

"One or more indexers are invalid. Make sure your Magento cron job is running. "

 

The above is what shows on my new install of Magento 2.2.5. I have installed this thing over and over again even went to a lower version and that didn't work so ended up back here.

I have googled so many times on this 1 issue and i CANNOT get it to go away, or work.

I read this post https://community.magento.com/t5/Magento-2-x-Admin-Configuration/How-to-make-sure-your-Magento-cron-... and tried what the last person done but that didn't do anything what so ever. I created cron jobs from other google articles but it still did not work.

The other issue is, store email addresses. I configured all of them to what i want them to be, but when i go and test each part of email. When an order confirmation is sent it sends from .inmotionhosting.com instead of my domain email i specified.

 

WHAT I NEED?

Is someone who is able to tell me btw i am brand new to making a website or anything about it and unfortunately google has not been able to help me here. I need easy step by step directions.

 

WHAT I HAVE?

My domain and web hosting is from inmotion. I am on shared hosting.

Php version 7.0.29, o.s Linux

Magento 2.2.5 installed via softaculous apps installer, installed on the main page of website.

 

Please help me to create the cron job and make it work or help make the message go away.

 

8 REPLIES 8

Re: Magento cron job How to. Please help

Hello @nora_grey,

 

To setup cronjob on server, Please follow below steps

Please log in on the server by the terminal

 

Find the PHP binary and php.ini path
To display the path to your PHP binary, enter

 

$ which php

A sample result follows:

 

 

/usr/bin/php

 

Create the cron job
To create a cron job for the Magento file system owner, enter the following command as a user with root privileges:

 

$ crontab -u <Magento file system owner username> -e

For example,

 

 

$ crontab -u magento_user -e

A text editor displays. (You might need to choose a text editor first.)

 

 

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

where

 

  • <path to php binary> is the absolute file system path to your PHP binary
  • <magento install dir> is the directory in which you installed the Magento software; for example, /var/www
  • | grep -v "Ran jobs by schedule" filters this message from the log, making any errors easier to spot

The first command (magento cron:run) reindexes indexers, sends automated e-mails, generates the sitemap, and so on. Usually, it’s associated with the PHP command line .ini file. The other two commands are used by the Component Manager and System Upgrade

 

--
If my answer is useful, please Accept as Solution & give Kudos

 

 

 

Re: Magento cron job How to. Please help

Thank you for replying and helping me.

First off. "Please log in on the server by the terminal" - i assume that is the ssh terminal? again i have tried a few "google tactics" to get this to work but every time i have gone to use this all it says is "network error connection timed out" so im back to being stuck again.

Is there a different way to get around this?

I followed a guide from inmotion to set up the ssh access and was told by the c.s that i am on shared hosting so i only have limit access, not sure if that is why it's not working for me?

Re: Magento cron job How to. Please help

Hello @nora_grey,

 

I have checked the guide for inmotionhosting ssh guide. Please check it, Maybe it will help you to connect ssh 

 

https://www.inmotionhosting.com/support/website/ssh/how-to-login-ssh

 

--
If my answer is useful, please Accept as Solution & give Kudos

Re: Magento cron job How to. Please help

Hi @gelanivishal

I used this https://www.inmotionhosting.com/support/website/ssh/shared-reseller-ssh as my guide as i am on shared hosting i don't have vps or dedicated, although it still did not work.

Re: Magento cron job How to. Please help


Create the cron job
To create a cron job for the Magento file system owner, enter the following command as a user with root privileges:

 

$ crontab -u <Magento file system owner username> -e

For example,

$ crontab -u magento_user -e

A text editor displays. (You might need to choose a text editor first.)

 @gelanivishal i have managed to get into the ssh terminal with this part (above)  i input the "magento file system owner username" as the MySQL DB User (not sure if that's correct) it came back with "must be privileged to use -u

 

I did try crontab -e and inputted info below (with my own path) but the message did not go away in admin. Am i at a loss here or can something else be done?

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

 

Re: Magento cron job How to. Please help

which php version is required for execution cron?

Re: Magento cron job How to. Please help

@nora_greyAs a beginner things can be little complicated. With the time you'll get the expertise on the things you are working one. I believe so far you have the SSH access and can do different things as you are able to set the CRON. For some reason it it still not working and I can understand that. To debug the same let's try to run CRON manually instead of CRONTAB.

 

To run the cron as well as indexing you can run the below command. In first attempt (if cron runs) it will create or schedule jobs to process at certain time. In 2nd attempt it will process some of those job and same thing goes on until all jobs are processed. Once all the job are processed it schedule next set of jobs.

 

Assuming you are connected to SSH and under your Magento installed directory, run below commands:

 

php bin/magento cron:run

php update/cron.php

php bin/magento setup:cron:run

 

If all above goes well means there is some issue with the cron setup else you'll see the issue in above command. For indexing you can run below command from your Magento installed directory.

 

php bin/magento indexer:reindex

 

Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.

- Tarandeep
Problem solved?Please give 'Kudos' and accept 'Answer as Solution'.

Re: Magento cron job How to. Please help

@olivier_rogneYou do not need a separate version of PHP to run the cron. However, cron run via command line. If you have multiple php version on your server in that case command line PHP version can be different than what you have for your website.

 

Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.

- Tarandeep
Problem solved?Please give 'Kudos' and accept 'Answer as Solution'.