cancel
Showing results for 
Search instead for 
Did you mean: 

I can't run a Cron job in CLI

SOLVED

I can't run a Cron job in CLI

CentOS Linux release 7.1.1503 (Core)
WHM version 11.52.1.3 (Root access)
Cpanel
Apache 2.4.16
PHP 5.5.30
MySQL 5.6
Magento-CE-2.0.0+Samples.* Extracted (.tar.bz2) on my server ,and ran the Setup Wizard.

 

After install Magento in Admin on top y see this message:

 

System messages

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

So I read this link http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html#config-cli-...

 

I really don't know about cron jobs. Then after read, I created a cron job,  But i can't run cron from the command line like next link

http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html#config-cli-...

 

I tryed :
I switched to the Magento file system owner. -> magentoadmst

Run :

[~/public_html/bin]# ./magento cron:run

Response : X-Powered-By: PHP/5.5.30
Content-type: text/html
bin/magento must be run as a CLI applicationmagentoadmst@magento.staging

 

[~/public_html/bin]# php magento cron:run

X-Powered-By: PHP/5.5.30
Content-type: text/html
bin/magento must be run as a CLI applicationmagentoadmst@magento.staging

 

Maybe, I don't know how to run a CLI ?

 

As I understand, after create a cron job I need to run it. 

 

Thanks,

 

Carlos

1 ACCEPTED SOLUTION

Accepted Solutions

Re: I can't run a Cron job in CLI

Hi @matt1237,

 

I just have one version of PHP. 

But, i solvented part of my problem runing like this . 

php-cli bin/magento cron:run

So I changed the command php for php-cli 

 

My Magento start working faster and better, but I still seeing same System message

 

I think is something about indexes

 

Thanks. 

View solution in original post

10 REPLIES 10

Re: I can't run a Cron job in CLI

Is PHP configured to run as CLI? what shows up if you type php -v on your prompt?

Re: I can't run a Cron job in CLI

Hi @maddyC,

 

Thanks

 

It show me :

php -vPHP

5.5.30 (cli) (built: Nov 30 2015 15:37:53) Copyright (c) 1997-2015 The PHP GroupZend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

 

Let me see, how can I figure out if PHP configured to run as CLI?

 

Carlos

Re: I can't run a Cron job in CLI

I think PHP configured to run as CLI .. I also tryed ... 

 

magentoadmst@magento.staging [~/public_html]#

php bin/magento cron:run

X-Powered-By: PHP/5.5.30

Content-type: text/html

bin/magento must be run as a CLI applicationmagentoadmst@magento.staging

Re: I can't run a Cron job in CLI

Do you have more than on version of PHP installed? If so, syou may need to specify the paticular php executable. PHP run from CLI might be different from the PHP run by your web user (Apache). Try specifying the fully PHP path to the version you want to run, something like:

/opt/rh/rh-php56/root/usr/bin/php -c /home/example/etc/php.ini /home/example/public_html/bin/magento setup:cron:run

Re: I can't run a Cron job in CLI

Hi @matt1237,

 

I just have one version of PHP. 

But, i solvented part of my problem runing like this . 

php-cli bin/magento cron:run

So I changed the command php for php-cli 

 

My Magento start working faster and better, but I still seeing same System message

 

I think is something about indexes

 

Thanks. 

Re: I can't run a Cron job in CLI

I'm having the exact same problem and I've tried several cron setups without any luck.

 

X-Powered-By: PHP/5.6.x

Content-type: text/html

bin/magento must be run as a CLI application

Re: I can't run a Cron job in CLI

@nimonogi try something like this for your cron job to reindex..

php-cli -q /home/mydomainname/public_html/bin/magento indexer:reindex >/dev/null 2>&1

 

possibly not the recommended method, but it works for me.

Re: I can't run a Cron job in CLI

This worked for me after hours of trying.... GO TO CPANEL

THEN TO CRON JOBS and configure them like this;

* * * * * /usr/bin/php-cli /home/<CPANEL FTP USER NAME>/public_html/bin/magento setup:cron:run >> /home/<CPANEL FTP USER NAME>/public_html/var/log/setup.cron.log

* * * * * /usr/bin/php-cli /home/<CPANEL FTP USER NAME>/public_html/update/cron.php >> /home/<CPANEL FTP USER NAME>/public_html/var/log/update.cron.log

* * * * * /usr/bin/php-cli /home/<CPANEL FTP USER NAME>/public_html/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /home/<CPANEL FTP USER NAME>/public_html/var/log/magento.cron.log

SWAP THIS FOR YOUR FTP USER NAME <CPANEL FTP USER NAME> AND CHECK THE FILE PATHS ARE ALL OK

Re: I can't run a Cron job in CLI

This worked for me after hours of trying....

* * * * * /usr/bin/php-cli /home/<CPANEL FTP USER NAME>/public_html/bin/magento setup:cron:run >> /home/<CPANEL FTP USER NAME>/public_html/var/log/setup.cron.log

* * * * * /usr/bin/php-cli /home/<CPANEL FTP USER NAME>/public_html/update/cron.php >> /home/<CPANEL FTP USER NAME>/public_html/var/log/update.cron.log

* * * * * /usr/bin/php-cli /home/<CPANEL FTP USER NAME>/public_html/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /home/<CPANEL FTP USER NAME>/public_html/var/log/magento.cron.log

SWAP THIS FOR YOUR FTP USER NAME <CPANEL FTP USER NAME> AND CHECK THE FILE PATHS ARE ALL OK